1
votes

I'm trying to force Word to show only the styles a group of people are going to work with. The following macro shows only the styles I want. But this only works if "Recommended" has been selected in the "Select styles to show" drop-down list from the Style Pane Options dialog box.

Is there a way to set this in vba so that when opening the document the user only sees the chosen styles?

Thanks,

D


Public Sub StyleSet()

' First, turn off all Style visibility:

For Each mystyle In ActiveDocument.Styles mystyle.Visibility = True Next mystyle

'update the styles

ActiveDocument.UpdateStyles

' Then, turn on the ones you want to see:

ActiveDocument.Styles("Click").Visibility = False ActiveDocument.Styles("Button").Visibility = False ActiveDocument.Styles("Caption").Visibility = False

'update the styles again
ActiveDocument.UpdateStyles

End Sub

1

1 Answers

0
votes

Do you want ... ?

ActiveDocument.FormattingShowFilter = wdShowFilterFormattingRecommended
ActiveDocument.StyleSortMethod = wdStyleSortRecommended