![]() |
|
#1
|
|||
|
|||
|
Hi,
I currently have a macro that is able to produce a list of all paragraph styles in a word document (see below). I was wondering if it is possible to adapt this code/create a new code to produce a list of charater styles instead of paragraph styles? Thanks Code: Code:
Sub CreateStyleList()
Dim docThis As Document
Dim styItem As Style
Dim sBuiltIn(499) As String
Dim iStyBICount As Integer
Dim sUserDef(499) As String
Dim iStyUDCount As Integer
Dim sInUse(499) As String
Dim iStyIUCount As Integer
Dim iParCount As Integer
Dim J As Integer, K As Integer
Dim sParStyle As String
Dim bInUse As Boolean
' Ref the active document
Set docThis = ActiveDocument
' Collect all styles being used
iStyIUCount = 0
iParCount = docThis.Paragraphs.Count
iParOut = 0
For J = 1 To iParCount
sParStyle = docThis.Paragraphs(J).Style
For K = 1 To iStyIUCount
If sParStyle = sInUse(K) Then Exit For
Next K
If K = iStyIUCount + 1 Then
iStyIUCount = K
sInUse(iStyIUCount) = sParStyle
End If
Next J
iStyBICount = 0
iStyUDCount = 0
' Check out styles that are "in use"
For Each styItem In docThis.Styles
'see if in those being used
bInUse = False
For J = 1 To iStyIUCount
If styItem.NameLocal = sInUse(J) Then bInUse = True
Next J
'Add to those not in use
If Not bInUse Then
If styItem.BuiltIn Then
iStyBICount = iStyBICount + 1
sBuiltIn(iStyBICount) = styItem.NameLocal
Else
iStyUDCount = iStyUDCount + 1
sUserDef(iStyUDCount) = styItem.NameLocal
End If
End If
Next styItem
'Now create the output document
Documents.Add
Selection.TypeText "Styles In Use"
Selection.TypeParagraph
For J = 1 To iStyIUCount
Selection.TypeText sInUse(J)
Selection.TypeParagraph
Next J
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText "Built-in Styles Not In Use"
Selection.TypeParagraph
For J = 1 To iStyIUCount
Selection.TypeText sBuiltIn(J)
Selection.TypeParagraph
Next J
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText "User-defined Styles Not In Use"
Selection.TypeParagraph
For J = 1 To iStyIUCount
Selection.TypeText sUserDef(J)
Selection.TypeParagraph
Next J
Selection.TypeParagraph
Selection.TypeParagraph
End Sub
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Font list character display
|
whabtewo | Word | 1 | 03-09-2014 08:12 PM |
MAcro to List all the Font & its size in a word document
|
shaukat74 | Word VBA | 1 | 01-29-2013 09:34 PM |
Restricting paragraph styles without restricting character styles
|
Red Pill | Word | 5 | 05-25-2012 01:06 PM |
Quick Styles Set saved but it doesnt appear at the styles list!
|
Pedro77 | Word | 3 | 10-15-2011 05:17 AM |
The list of styles appears in different way in different document?????
|
Jamal NUMAN | Word | 4 | 04-28-2011 05:40 AM |