Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
xtine xtine is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
xtine xtine is offline
external usenet poster
 
Posts: 15
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Manage styles window query, revisited Tom Smith New Users 0 March 13th 08 08:44 PM
Manage Styles window query Tom Smith New Users 29 February 22nd 08 03:13 PM
How to properly manage styles in Word 2003? Dino Hsu Formatting Long Documents 1 January 11th 06 10:22 AM
How to Manage Changes Brian Microsoft Word Help 1 December 6th 05 02:53 AM
manage styles in a template KaBur Microsoft Word Help 1 September 30th 05 10:35 PM


All times are GMT +1. The time now is 08:31 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"