View Single Post
 
Old 04-13-2021, 02:42 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For example:
Code:
Sub StyleCleaner()
Dim wdDocA As Document, wdDocB As Document, Stl As Style, StrStl As String
Set wdDocA = ActiveDocument: StrStl = "|"
With wdDocA
  Set wdDocB = Documents.Open(FileName:=.AttachedTemplate.FullName, AddToRecentFiles:=False, Visible:=False)
  With wdDocB
    For Each Stl In .Styles
      If Stl.BuiltIn = False Then StrStl = StrStl & Stl.NameLocal & "|"
    Next
    .Close False
  End With
  For Each Stl In .Styles
    With Stl
      If .BuiltIn = False Then
        If .InUse = False Then
          If InStr(StrStl, "|" & .NameLocal & "|") = 0 Then .Delete
        End If
      End If
    End With
  Next
End With
MsgBox "All Done.", vbOKOnly
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote