Paragraph styles currently used

J

Jose Valdes

This script is supposed print a list of paragraph styles that are currently
used in the document. Unfortunately, it fails to capture paragraph styles
that are used in headers and footers. Can anyone suggest ways of expanding
the scope to capture header/footer content? Thanks! Jose

Sub DisplayStylesInUse()

Dim para As Paragraph
Dim sty As Style
Dim StirPara As String
Dim AllStyles As String
Dim ResultOfCompare As Long

AllStyles = "Normal"

For Each para In ActiveDocument.Paragraphs

StirPara = para.Style.NameLocal
ResultOfCompare = InStr(1, AllStyles, StirPara, 1)
If ResultOfCompare = False Then
AllStyles = AllStyles & "| " & StirPara
End If

Next para

Selection.EndKey Unit:=wdStory
Selection.TypeText Text:=AllStyles

End Sub
 
J

Jay Freedman

The article http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm
explains about the StoryRanges collection, and how headers, footers, text
boxes, footnotes and endnotes, and comments aren't part of the main
document.

Adapt the loops shown there to search through all the story ranges for
styles in use.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jose Valdes

Thanks!
Jay Freedman said:
The article http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm
explains about the StoryRanges collection, and how headers, footers, text
boxes, footnotes and endnotes, and comments aren't part of the main
document.

Adapt the loops shown there to search through all the story ranges for
styles in use.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
 

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