Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Manage Styles using VBA?
Can you programmatically control the styles that are shown in the
Style Gallery and in the styles list (where they are previewed)? Can you write macros to permit/hide etc. the built-in styles? Christine |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Manage Styles using VBA?
Lene Fredborg has posted the following reply to a similar question:
**************** Maybe you are looking for something like the following macro. The macro uses the Visibility property of the styles to first hide all styles and then show the styles that are included in oArray. In this example, the built-in styles "Heading 1", "Heading 2" and "Body Text" plus the custom style "MyStyle" will be shown whereas all other styles will be hidden. As explained in the comment in the macro, setting the Visibility property to _true_ means that the style will _not_ be shown (seems rather illogical to me but that is how it works). I have found no documentation of Visibility in the VBA help. Originally, I found the property by recording a macro while changing the check marks in the Format Settings dialog box that opens when you select Custom from the Show field in the Styles and Formatting task pane. The styles whose visibility you set to false will be checked in the Format Settings dialog box. Sub ShowHideStyles() Dim oSty As Style Dim oArray As Variant Dim n As Long 'Start deselecting all - NOTE Visibility = true means NOT CHECKED! With ActiveDocument For Each oSty In .Styles .Styles(oSty.NameLocal).Visibility = True Next oSty 'Display the desired styles - include the names in oArray oArray = Array(wdStyleHeading1, wdStyleHeading2, wdStyleBodyText, _ "MyStyle") For n = LBound(oArray) To UBound(oArray) .Styles(oArray(n)).Visibility = False Next n End With End Sub **************** -- Stefan Blom Microsoft Word MVP "xtine" wrote in message ... Can you programmatically control the styles that are shown in the Style Gallery and in the styles list (where they are previewed)? Can you write macros to permit/hide etc. the built-in styles? Christine |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Manage Styles using VBA?
Thanks
this looks like what I was looking for... will try it out soon Christine On Apr 15, 11:03 am, "Stefan Blom" wrote: Lene Fredborg has posted the following reply to a similar question: **************** Maybe you are looking for something like the following macro. The macro uses the Visibility property of the styles to first hide all styles and then show the styles that are included in oArray. In this example, the built-in styles "Heading 1", "Heading 2" and "Body Text" plus the custom style "MyStyle" will be shown whereas all other styles will be hidden. As explained in the comment in the macro, setting the Visibility property to _true_ means that the style will _not_ be shown (seems rather illogical to me but that is how it works). I have found no documentation of Visibility in the VBA help. Originally, I found the property by recording a macro while changing the check marks in the Format Settings dialog box that opens when you select Custom from the Show field in the Styles and Formatting task pane. The styles whose visibility you set to false will be checked in the Format Settings dialog box. Sub ShowHideStyles() Dim oSty As Style Dim oArray As Variant Dim n As Long 'Start deselecting all - NOTE Visibility = true means NOT CHECKED! With ActiveDocument For Each oSty In .Styles .Styles(oSty.NameLocal).Visibility = True Next oSty 'Display the desired styles - include the names in oArray oArray = Array(wdStyleHeading1, wdStyleHeading2, wdStyleBodyText, _ "MyStyle") For n = LBound(oArray) To UBound(oArray) .Styles(oArray(n)).Visibility = False Next n End With End Sub **************** -- Stefan Blom Microsoft Word MVP |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Manage styles window query, revisited | New Users | |||
Manage Styles window query | New Users | |||
How to properly manage styles in Word 2003? | Formatting Long Documents | |||
How to Manage Changes | Microsoft Word Help | |||
manage styles in a template | Microsoft Word Help |