"Touching" all the styles in a template

D

Dodiad

I have been looking at the MVP article by Dave Rado, Margaret Aldis, Ian
Sharpe, and Beth Melton titled "How to safely update a document's styles from
its template without using the Organizer." The article mentions that in order
for all of the template's styles to be updated correctly into a document
based on it, the styles must not only appear in the "Styles in use" list in
the template's Format + Style dialog, but must also at least once have been
physically applied to text in the template. To ensure this, the article
recommends creating a dummy paragraph in the template, cycling it through all
of the styles in the "in use" list, and then deleting it.

My question is this: Is it sufficient to run a VBA macro to "touch" all of
the template's styles--something like

Sub TouchStyles()

Dim dummyParagraph as Paragraph

With ActiveDocument.Paragraphs

.Add
Set dummyParagraph = .Last

Dim eachStyle As Style
For Each eachStyle In ActiveDocument.Styles
dummyParagraph.Style = eachStyle
Next 'eachStyle

End With 'ActiveDocument.Paragraphs

End Sub 'TouchStyles

Will this do the trick, or is it necessary to apply all of the styles by
hand, using the mouse from the Styles dialog?
 
K

Klaus Linke

Your code looks great. Maybe you'd want to remove the last paragraph when
you're done.

Another thing you may want to look out for is that there are also character
styles, table styles, and list styles.
If you're just interested in updating paragraph styles (which include the
new "linked styles" in Word 2007), you could add a "Select Case
eachStyle.Type : Case wdStyleTypeParagraph" before applying the style... or
add any other types you want to update to the Case statement.

Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top