Update to Match Selection with VBA

Can the "Update to Match Selection" operation defined in the Styles dialog be executed with VBA?

shachoAsked:
Who is Participating?
 
Eric FletcherConnect With a Mentor Commented:
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
 
GrahamSkanRetiredCommented:
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
 
shachoAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
GrahamSkanRetiredCommented:
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
 
shachoAuthor Commented:
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
 
shachoAuthor Commented:
Is there really no way to do this?

Mike
0
 
shachoAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.