Here’s one way to make a list of all the fonts used in a Word document. Sometimes there are stray fonts used in a Word document, perhaps from earlier versions or unused formatting trials. Even a single letter or blank paragraph set to a font can make a difference.
Removing these fonts isn’t just being tidy, unnecessary fonts can enlarge a document with embedded fonts or a PDF made from the document.
There are two methods of making a font list:
- Use VBA code to make a list.
- Dig into the document structure to reveal the included font list, see List fonts in a Word document – method 2
Once you have a list of fonts you can find or replace specific fonts in a Word document.
List fonts with VBA
There are various chunks of VBA code that will make a list of the fonts in a document.
Many take a long time to run and while running Word is locked up.
We’ve made this code which is simple, fast and can be run on any Word document. The results appear as a simple text list in the Immediate window (we’ll explain where that is) ready to be copied anywhere you like.
Using StoryRanges means all parts of the document should be checked including headers, footers, footnotes and endnotes.
A collection object to make a unique font list removes the need to check for duplicates.
Putting the font list into the Immediate window is faster, more contained and easily copyable.
The Application.ScreenUpdating = False/True
lines might help speed up the code in a large document.
The full code is below.
How to run the font list code
This code can be run on any Word document as a ‘one off’, not just a macro-enabled .dotm file. This is NOT the standard way to add VBA to an Office document, it’s a simplified version for adding code to run only while the doc is open.
Open the document then switch to the Developer tab. Developer now showing – see here.
Choose Developer | Visual Basic to open the VBA editor. Right-click on the document you want to check. Look for the Project with the name of the document then “Microsoft Word Objects” and ThisDocument and finally “View Code”
“View Code” will open a code window for this document (we’re not bothering with Modules for this quick use).
Open Immediate window
Open the Immediate so you can see the font list View | Immediate Window.
Immediate window is normally used to for quick testing or debugging using Debug.Print commands.
Run the Font List code
Now the VBA editor should look like this with the document selected in the left-pane.
Click the Run button on the toolbar. If the document is large, there’ll be a wait of perhaps a few minutes for really big docs.
Here’s one result from our tests showing 27 different fonts in a large document.
That’s way more than there should be, so there’ll be some font hunting (Advanced Search) to search the text by font and change any stray font formatting.
List fonts in document – full code
Sub ListFontsInDocument()
Dim doc As Document
Set doc = ActiveDocument
Dim fontList As Collection
Set fontList = New Collection
Application.ScreenUpdating = False
Dim rng As Range
For Each rng In doc.StoryRanges
Dim chars As Characters
Set chars = rng.Characters
Dim char As Range
For Each char In chars
On Error Resume Next
fontList.Add char.font.Name, CStr(char.font.Name)
On Error GoTo 0
Next char
Next rng
Application.ScreenUpdating = True
Dim fontName As Variant
For Each fontName In fontList
Debug.Print fontName
Next fontName
Debug.Print "Total Fonts: " & fontList.Count
End Sub
Copying the code above should work OK in Edge/Chrome browsers.
With Firefox, we’re told there are problems, probably related to the end of line breaks. Make sure that each code line ends with a full line break, if necessary replace each end of line with a press of the ‘Enter’ key.
List fonts in a Word document – method 2 is another way to get a font list.
Use Google Fonts for free in Microsoft Office
Check out the winner and other new fonts in Microsoft 365/Office 2021
Find out more about fonts