Advertisement
omegastripes

VBA Word Removing Unused Styles

Aug 31st, 2022
1,953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 0.60 KB | Source Code | 0 0
  1. ' Removing Unused Styles by Allen Wyatt (last updated January 15, 2020)
  2. ' https://word.tips.net/T001337_Removing_Unused_Styles.html
  3.  
  4. Sub DeleteUnusedStyles()
  5.     Dim oStyle As Style
  6.  
  7.     For Each oStyle In ActiveDocument.Styles
  8.         'Only check out non-built-in styles
  9.        If oStyle.BuiltIn = False Then
  10.             With ActiveDocument.Content.Find
  11.                 .ClearFormatting
  12.                 .Style = oStyle.NameLocal
  13.                 .Execute FindText:="", Format:=True
  14.                 If .Found = False Then oStyle.Delete
  15.             End With
  16.         End If
  17.     Next oStyle
  18. End Sub
Tags: vba word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement