?
Solved

Update to Match Selection with VBA

Posted on 2007-10-10
9
Medium Priority
?
639 Views
Last Modified: 2008-05-20
Can the "Update to Match Selection" operation defined in the Styles dialog be executed with VBA?

0
Comment
Question by:shacho
  • 4
  • 2
7 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20047340
Mike, which version of Office is that in? I can't find it in 2003. The closest I get is 'Automatically update' on the 'Modify Style' dialogue.
0
 

Author Comment

by:shacho
ID: 20047829
2003.  The problem is that despite the fact that protection is engaged on the form (which should prevent the user from making any alterations to formats and styles), if that nonsense autocorrect option that auto indents paragraphs is active on the client, sometimes it mangles the style, resulting in style variants for certain paragraphs.  I can't seem to prevent this, but if I can add code that rectifies these problem in an event handler it should suffice.

Mike
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20051429
I think that it would be a bit complicated trying to undo indeterminate style changes. Perhaps it would be better to consider copying the style from a 'master template' using OrganizerCopy

0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:shacho
ID: 20053134
The style itself is in tact.  What happens is that specific sections of the text that have the style applied get augmented by the autocorrect, which slips in beneath the protection radar.  So I'll have three paragraphs, for example, that have the style "stlContent" applied.  Two are pure "stlContent".  One is "stlContent + Indent 3pts" or something along those lines.  Turning off protection and clicking "Update to Match Selection" in the styles dialog wipes out all of these additions to the styles and brings every section back to pure, unadulterated "stlContent".  If I could do the same thing with code, the problem would be easy to solve.  Is there anyway to achieve this with Word.Dialogs( ) perhaps?

Mike
0
 

Author Comment

by:shacho
ID: 21546738
Is there really no way to do this?

Mike
0
 
LVL 21

Accepted Solution

by:
Eric Fletcher earned 2000 total points
ID: 21582753
Shacho: GrahamSkan asked me to take a look at this.

I assume you are referring to the option available from right-clicking a listed item in the Styles and Formatting panel of the Task Pane. This is available when the selection is within formatting that differs from that of the listed item: if you choose 'Update to match selection', the item's style definition gets updated, and all instances of it within the document will take on the attributes of the current selection. It acts like the 'Automatically update' on the 'Modify Style' dialog.

As far as I know, the tasks in this panel don't have direct VBA equivalents. The task pane enables users to perform actions using "deeper level' features of Word more easily, but it seems to be designed to just give easier access to these features.

Suggestions?

1. Would having the user alerted be acceptable? If so, turn on the "Prompt to update style' checkbox in the Tools Options Edit dialog.

2. Could you prevent the issue by turning off the related autocorrect settings with an AutoOpen macro? (i.e. the dreaded 'Autoformat As You Type' settings) I realize that this might be considered "rude" behaviour if someone has deliberately set these on, but I suppose you could always alert them to the irrationality of their ways if your code found them set on. ;-)

Sorry I can't be of more help; this is similar to questions I've seen discussed in other posts, and I've not seen a solution.
0
 

Author Comment

by:shacho
ID: 21604730
Fair enough.  I genuinely doubt anybody in this group intentionally uses that feature.  Shutting it off for the duration of the session and restoring the original setting on exit would be more than sufficient.  In fact just shutting it off, on balance, would be the "better" thing to do.  Thanks for the suggestion.

Cheers,

Mike
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question