Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Highlight Words from a Word List.

Highlight Words from a Word List

Written by Allen Wyatt (last updated March 7, 2026)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


Paul has a document that he needs to check against a word list contained in another document. If the document being checked contains one of the words in the list, then the word in the document (not in the word list) needs to be highlighted. The word list is large, on the order of 20,000 words, and Paul is wondering what the best way to do this is.

The easiest way to do this is to write your own macro that will do the comparisons for you. Start by putting the words you want find in their own document. Put one word (or phrase) per paragraph (just press Enter after each word or phrase), and make sure the document is named "checklist.docx." With the document in the C: drive, the following macro can be used:

Sub CompareWordList()
    Dim sCheckDoc As String
    Dim docRef As Document
    Dim docCurrent As Document
    Dim p As Paragraph
    Dim sLookWord As String

    sCheckDoc = "c:\checklist.docx"

    If Dir(sCheckDoc) = "" Then
        MsgBox "Checklist file not found."
        Exit Sub
    End If

    Set docCurrent = ActiveDocument
    Set docRef = Documents.Open(sCheckDoc)
    Options.DefaultHighlightColorIndex = wdYellow

    With docCurrent.Content.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
        .Wrap = wdFindContinue
        .Replacement.Highlight = True
        .Replacement.Text = "^&"

        For Each p In docRef.Paragraphs
            sLookWord = Trim(Replace(p.Range.Text, vbCr, ""))
            If Len(sLookWord) > 0 Then
                .Text = sLookWord
                .Execute Replace:=wdReplaceAll
            End If
        Next p
    End With

    docRef.Close False
End Sub

All you need to do is have the document open that you want checked, and then run the macro. If the document containing the words to check is named differently or in a different location, just change the line that sets sCheckDoc so that it has a different full path name for the document.

Basically, the macro grabs each word or phrase from checklist.docx and then does a Find and Replace operation using that word in the document. If the word is found, then it is highlighted in yellow. The macro also pays attention to case in what it finds. Thus, if your search word is "luckily," then it will only highlight the word if it is lowercase, meaning if a sentence begins with "Luckily," then it would not be highlighted.

You can put as many words in the checklist.docx document as you want, but understand that a Find and Replace is done for each of them. That means that if it contains a lot of words and the document you are searching is large, the macro can take quite a while to run. Paul said that he had 20,000 words that needed to be checked for, which means that the macro would do 20,000 Find and Replace operations. That may be enough time to take a lunch break while the macro is running.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1173) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Highlight Words from a Word List.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Finding and Changing Word's Internal Commands

If you know how to create macros, you can easily create entire replacements for Word's internal commands. Here's all you ...

Discover More

Returning an ANSI Value

Need to know the character value of the first character in a string? It's easy to do, without using a macro, by using the ...

Discover More

Aligning Numbered Lists on the Period

Adding a numbered list to a document is easy. Getting that list to look exactly as you want can be more troublesome. In ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2021 or Microsoft 365. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word Step by Step today!

More WordTips (ribbon)

Moving the Insertion Point to the Beginning of a Line

If you need to move the insertion point within your macro, then you'll want to note the HomeKey method, described in this ...

Discover More

Creating a New Document in VBA

When working with documents in a macro, it makes sense that you may need to create a document from time to time. Here's ...

Discover More

Moving the Insertion Point to the End of a Line

When writing a macro to process the text in a document, you may need to move the insertion point to the end of a line. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine less than 9?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.