If you use Word to write an occasional letter, you probably don’t think about Word styles too often. On the other hand, some users may see styles as a formatting jungle. One of the main reasons styles confuse users is because there are so many and most of them go unused. The Styles panel is a good way to reduce the number of styles you interact with, but eventually you may want to remove all unused styles from a finished document. In this article, I’ll show you a VBA procedure that will delete all unused styles in the current document. Keep in mind, though, that you can’t remove built-in styles at all, so this is a workaround for documents with unused custom styles.
SEE: Software Installation Policy (Tech Republic Premium)
I use Microsoft 365 on a Windows 10 64-bit system, but you can use an earlier version. For your convenience, you can: download the demonstration .docm, .doc and .cls files† Word for the web does not support VBA procedures.
Why delete unused styles in Word?
Most of us only use a few styles in a regular document, but the underlying template has dozens of built-in styles. Add custom styles and you can see things get out of hand. There are three good reasons why you may want to remove unused styles from a document:
- In a large document with a lot of custom styles that you don’t use, you might see a bit of a performance hit. It’s not much of a problem with today’s systems loaded with RAM, but removing the unused styles is an option.
- It is a good idea to remove unused styles from a Word document that you want to distribute to many people. Doing so makes it harder for recipients to change the formatting, which can mess up the entire document.
- You inherit the maintenance of an older document that needs some tidying up.
Image A displays the Quick Styles gallery for the demonstration document. Click the Styles group’s dialog launcher to see even more. These are usually built-in styles supported by Normal, the underlying template. A few are custom styles. Most documents will not use most of these styles. But this gives you a glimpse into styles – there are many, and most of them are built-in, that can’t be removed.
Image A

It won’t take long for a document to be flooded with many custom but unused styles if you save custom styles in the Normal template. In this case, each new document comes with a lot of style baggage. To quickly see how many styles you have in use in a Word document, do the following:
- Click the Starter dialog box of the Styles group.
- At the bottom of the Styles pane, click Options.
- In the resulting dialog box, choose In Use from the Select Styles in Use drop-down list (Figure B†
- Click OK.
Figure B

Figure C

As you can see in Figure C, the Styles panel shows only the styles that are currently in use – only seven! However, only one custom style is in use. I wonder how many unused custom styles we can delete.
How to enter the procedure in Word
You could try removing styles one by one, but that sounds awful. You can use Replace to remove unused styles, but again, you do this one at a time. With both methods, you need to know which styles are not used. The Word VBA procedure in Advertisement A mimics a replacement task. I recommend that you do this procedure on a copy, just in case.
Advertisement A
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
To enter the procedure, press Alt + F11 to open the Visual Basic Editor (VBE). In the Project Explorer on the left, select ThisDocument and enter the procedure as shown in Figure D† You can enter the code manually or import the downloadable .cls file. In addition, the macro is contained in the downloadable .docm, .doc, and .cls files. If you enter the code manually, do not paste it from this web page. Instead, copy the code into a text editor and then paste that code into the ThisDocument module. Doing this will remove any ghost web characters that might otherwise cause errors.
Figure D

If you are using a ribbon version, make sure to save the workbook as a macro file. If you are working in the menu version, you can skip this step.
To perform the procedure, click the Developer tab, and then click Macros in the Macros group. In the resulting dialog box, shown in Figure E, select the DelUnusedStyles procedure and click Run. The procedure cycles through the Styles collection and removes all unused styles except the built-in styles.
Figure E

Most likely, you don’t want to go through all those steps to run this macro. I recommend adding it to the Quick Access Toolbar or a custom group. If you need help with that, read Add Office macros to the QAT toolbar for quick access†
Keep in mind that you can’t remove the built-in styles, but you can reduce the number of custom styles available in the Styles panel by changing Recommended to In Use, as we did before. In this case, the Styles panel still displays the same list because those styles are in use. The procedure does not tell you how many, if any, have been removed. In the case of this simple document, the procedure may not have removed any style. You want to save this procedure for those long and old documents that several people have worked on before you. Or for all documents, if you save all custom styles in Normal.
This procedure or other closely related tasks have been around for a long time. I can’t take credit for it, but it’s easy to adapt to your needs.
How the VBA procedure works in Word
The DelUnusedStyles procedure is easy to understand and maintain. It mimics Word’s Replace function, specifying a style by name as the search string and leaving the replace string empty. In fact, you could record and renew much of this procedure. However, you will find that the registration procedure contains a lot of unnecessary code and uses explicit selections, which is inefficient. DelUnusedStyles is concise and efficient.
After the variable s is declared as a Word style, the For Each construct cycles through all the styles in the Styles collection. If the Built-in property is False, meaning the style is not a built-in style, the With block sets the necessary search properties:
- .ClearFormatting removes all formatting used in a previous search.
- .Style is set to the name of the current style (s is the Styles variable).
- .Execute executes the task without any text in the search string.
If the current style’s .Found property is False, the procedure removes it. The procedure repeats this cycle for each style in the current document.
If you find yourself using the procedure often, add it to Personal.xlsb or to the Quick Access Toolbar (QAT) for quick access. For more information about Personal.xlsb, read: Create a VBA procedure that closes all open workbooks in Excel†