Written by Allen Wyatt (last updated February 3, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
Derek needs a way to find, in a document, the next time the typeface (font name) changes. For instance, if the insertion point is within the middle of the document, he would like Word to let him know, starting at that point, where the next change occurs. Derek wonders if there is a way to accomplish such a task.
There is no built-in way to accomplish this task, though you may be able to visually tell when the typeface has changed. I can often tell by simply increasing the zoom factor for the document (say, to 200% or 250%) and then visually scanning the document to look for changes in appearance. Of course, this will depend on the visual disparity between the two adjacent fonts.
If you prefer a macro-based solution, you could create one that saves the typeface name at the current insertion point location and then steps through each remaining character of the document. If the typeface differs from the original one, then you can notify the user. Here is an example of such a macro:
Sub ChangeOfFont() Dim fntName As String Dim aRange As Range Set aRange = Selection.Range aRange.Collapse Direction:=wdCollapseStart aRange.MoveEnd Unit:=wdCharacter fntName = aRange.Font.Name Do aRange.MoveEnd Unit:=wdCharacter aRange.MoveStart Unit:=wdCharacter Loop Until aRange.Font.Name <> fntName Or _ aRange.Bookmarks.Exists("\EndOfDoc") aRange.Select If aRange.Bookmarks.Exists("\EndOfDoc") Then MsgBox "End of document" Else MsgBox "Font change from " & fntName & " to " & aRange.Font.Name End If End Sub
The majority of work is done in the Do loop, where each character's font is checked to see if it has changed. Note that the loop also checks to see if the end of the document is reached, at which point you would want the macro to stop.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5131) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
Want to give your macros a different name than they currently use? It's easy to do using the VBA Editor as described here.
Discover MoreIf you are applying formatting from within a macro, you may want to change the alignment of various paragraphs. Here's ...
Discover MoreIf you want a list of all the fonts used in a document, the answer isn't as simple as you may think. This tip uses macros ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments