-
This can be done.
Here is code that will list, in a new doc, the styles in a document that are NOT built-in styles.
This would have to be expanded to also run a check for each paragraph to see if it uses a built-in style, or not.
There is a possible problem of course. If, like most users, the document has those "empty" paragraphs, when people use an "extra" Enter key to make space between paragraphs - because they do not know how to properly use Styles, each one of those "empty paragraphs will beparsed and checked as well.
So you could add a string check to see if the Range.Text of each checked paragrpah is "".
Can you take it from here, or do you need help with this?
[vba]Sub ShowStyles()
Dim aStyle As Style
Dim i As Integer
Dim ThisDoc As Document
Dim ThatDoc As Document
Set ThisDoc = ActiveDocument
Application.Documents.Add
Set ThatDoc = ActiveDocument
ThisDoc.Activate
For Each aStyle In ThisDoc.Styles
If aStyle.BuiltIn <> True Then
i = i + 1
ThatDoc.Activate
With Selection
.TypeText Text:="SampleText of the Style named: " & aStyle.NameLocal
.Style = aStyle
.TypeParagraph
End With
ThisDoc.Activate
End If
Next
ThatDoc.Activate
Selection.HomeKey unit:=wdStory
Selection.TypeText Text:="There are " & i & _
" Styles that are NOT built-in."
Selection.TypeParagraph
Selection.TypeParagraph
ThisDoc.Activate
Set ThisDoc = Nothing
Set ThatDoc = Nothing
End Sub[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules