Removing styles
Regards,
Klaus
Sub DeleteUnusedStyles()
Dim myStyle As Style
For Each myStyle In ActiveDocument.Styles
If myStyle.InUse Then
Select Case myStyle
Case ActiveDocument.Styles(wdStyleDefaultParagraphFont)
Case ActiveDocument.Styles(wdStyleNormal)
Case ActiveDocument.Styles(wdStyleNormalTable)
Case ActiveDocument.Styles(wdStyleHeading1) To _
ActiveDocument.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
If MsgBox("Delete?", vbYesNo, myStyle.NameLocal) = vbYes Then
myStyle.Delete
End If
Else
If MsgBox("Keep?", vbYesNo, myStyle.NameLocal) = vbNo Then
myStyle.Delete
End If
' End
End If
End With
End Select
End If
Next myStyle
End Sub
Hi Klaus:
Thank you for this, but mine crashed... it never addressed the style I was
trying to get rid of (I have a reoccurring problem with certain styles
popping up (usually a font/indent oddity created by someone else) and I'm
unable to erase them). It crashed at teh 'no list' style and gave me a
run-time '4198' error. When I click debug, it highlights the myStyle.Delete
line of code.
I usually select all instances of the offending Word-created style and just
hit delete, but once in a while, there are these buggy ones that linger and
they drive me crazy. I try to select them, and nothing selects. I try to
delete the style and nothing happens.
I'm wondering if anyone knows another way?
My offenders a 10 pt, Befo 0 pt; 10 pt, Bold, left: .83" space before
0 pt and their bold brethren.
I've scoured these groups to try to solve this, and it is driving me batty.
Any help would be great!
|