There are three steps to cleaning up unused Styles in Word:
See https://www.techrepublic.com/article/delete-unused-styles-using-vba-word/
Note that the other method using inUse (see https://answers.microsoft.com/en-us/msoffice/forum/all/remove-all-unused-styles-in-style-pane-at-once/bec9aafa-b719-46d1-9c37-d2eaa79da22c) doesn't delete all unused Styles - it only deletes styles that have never been used (https://learn.microsoft.com/en-us/office/vba/api/word.style.inuse).
Sub DelUnusedStyles()
'Delete all unused styles, except for built-in styles,
'in the current document.
'You can't delete built-in styles.
Dim s As Style
For Each s In ActiveDocument.Styles
'Only execute With if current s isn't a built-in style.
If s.BuiltIn = False Then
With ActiveDocument.Content.Find
.ClearFormatting
.Style = s.NameLocal
.Execute FindText:="", Format:=True
If .Found = False Then s.Delete
End With
End If
Next
End Sub
Alternatively here is a more robust macro from https://answers.microsoft.com/en-us/msoffice/forum/all/word-2010-how-does-one-remove-any-unused-styles-in/d9d879ea-d89f-453d-bc8e-6d3dd6f4e48d with an addition that copies over all the styles from the master template at the end.
Public Sub DeleteUnusedStyles()
' Delete unused Styles
Dim objStyle As Word.Style
Dim intBuiltInStyles As Integer
Dim intStyle As Integer
Dim defaultpath As String
Dim templateName As String
On Error Resume Next
ActiveDocument.Unprotect
'Count the number of built-in styles in this document
For Each objStyle In ActiveDocument.Styles
If objStyle.BuiltIn Then
intBuiltInStyles = intBuiltInStyles + 1
End If
Next objStyle
'Show summary and ask permission to continue
If MsgBox("There are " & ActiveDocument.Styles.count - intBuiltInStyles & _
" custom style(s) in this document." & vbCrLf & vbCrLf & _
"Delete unused custom styles?", vbOKCancel + vbExclamation, _
"Delete Unused Styles") = vbOK Then 'OK to continue
'Run through all the styles in the document BACKWARDS so we only delete styles from the end of the collection
For intStyle = ActiveDocument.Styles.count To 1 Step -1
If Not ActiveDocument.Styles(intStyle).BuiltIn Then
'This is a custom style see if it is in use
With ActiveDocument.Content.Find
On Error Resume Next
.ClearFormatting
.Style = intStyle
.Execute Format:=True
If Not .Found Then
'Style is not in use we can delete it
With ActiveDocument.Styles(intStyle)
'If this style is linked to another we have to unlink them otherwise both styles will be deleted which causes problems -
'this style may be linked to a built-in style which will cause an error if we try to delete it.
If .Type <> wdStyleTypeCharacter Then
'Character styles can't be linked from, only linked to the Linked property only exists in Word 2007 and above
If .Linked Then
'The LinkStyle property only exists in Word 2002 and above
If Not .LinkStyle Is ActiveDocument.Styles(wdStyleNormal) Then
.LinkStyle = wdStyleNormal
End If
'LinkStyle is a very badly behaved property and this is the closest we can get to unlinking styles short of copying all -
'text except the last paragraph mark to a new document.
On Error Resume Next
End If
On Error Resume Next
End If
'Ignore any error caused by trying to delete a style whose name begins with a space
On Error Resume Next
.Delete
On Error GoTo 0
End With
End If
End With
End If
Next intStyle
End If
'Copy Styles from Template
On Error Resume Next
ActiveDocument.Unprotect
'get templatename
templateName = ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate).Value
'get path and templatename
defaultpath = ActiveDocument.AttachedTemplate.path & "\" & templateName
'Copy all Styles from a special template
ActiveDocument.CopyStylesFromTemplate (defaultpath)
'reactivate Protection
ActiveDocument.Protect Password:="", NoReset:=False, Type:=wdNoProtection, UseIRM:=False, EnforceStyleLock:=True
'Display summary
MsgBox "Delete job has successfully finished", vbInformation, "Information"
End Sub
In File > Options
Activate the Styles Pane by pressing CTRL-ALT-SHIFT-S.