Word.Tips.Net WordTips (Menu Interface)

Highlight Words from a Word List

Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Highlight Words from a Word List.

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 by being made bold. The word list is large, on the order of 20,000 words, and Paul is wondering what the best way to do this is.

There are two ways you can proceed. The first is to write your own macro that will do the comparisons for you. If you put the words you want checked into a document named "checklist.doc" in the C: drive, then the following macro can be used:

Sub CompareWordList()
    Dim sCheckDoc As String
    Dim docRef As Document
    Dim docCurrent As Document
    Dim wrdRef As Object

    sCheckDoc = "c:\checklist.doc"
    Set docCurrent = Selection.Document
    Set docRef = Documents.Open(sCheckDoc)

    With Selection.Find
        .Replacement.Font.Bold = True
        .Replacement.Text = "^&"
        .Forward = True
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
    End With

    For Each wrdRef In docRef.Words
        If Asc(Left(wrdRef, 1)) > 32 Then
            With Selection.Find
                .Wrap = wdFindContinue
                .Text = wrdRef
                .Execute Replace:=wdReplaceAll
            End With
        End If
    Next wrdRef

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 from the word list and then does a Find and Replace operation using that word in the document. If you have many, many words in the word list, then the macro can take quite a while to run—20,000 Find and Replace operations is quite a few!

The other approach you can try is to use a third-party application to do the work for you. There is a good article and application available free at this site:


This approach is particularly interesting because it doesn't just make matched words bold, but allows you to set them to some color that you may desire.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (502) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Highlight Words from a Word List.

Related Tips:

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Amy    03 Mar 2016, 14:52
I would like to do the same thing as listed above, but instead of highlight/bold the word, I would like to delete the word. I have a word document that has a list of words. I want to search another word document for words on the list and delete them. How do I alter this macro to delete the words in stead of highlight/bold the words?
Darrell    04 Feb 2016, 13:35
What does your Checklist.doc file look like? It should have each search term on a separate line (with a hard return between each).
Nitin Jain    02 Feb 2016, 05:58
Hi I tried this code and I'm stuck in the for loop as the loop runs only once. I'm getting run time error as for loop not initialized. Pleaes help
Darrell    01 Feb 2016, 15:00
Rachel, I inserted the macro into Word 2010 (open Word, then select Developer tab, Macros button, then type a name for the macro, then hit Create button. Paste the macro into this box, then save it). To run the macro, open a Word document, select Developer tab, Macros, then highlight the macro you just named and hit Run. But before you run the macro, you'll need to create a separate Word document containing all the terms you want the macro to highlight. The full path and name of that document must be included in the line "sCheckDoc =" in the macro itself.
Rachel Jenkins    16 Jan 2016, 03:32
I am NOT a macro expert at all, so I probably messed this up. I put the above listing into Visual Basics Editor into any field I thought would accept it. I went into my word doc that I want to highlight words in and found the macro "CompareWordList" and when I run it, it says "Sub or Function not defined." What should I do now?
Thom    18 Dec 2015, 03:34
I'm using Peter's script to serch for single words or word combinations and it works fine! But how do I make the macro search just for whole words?
I mean, if one of the words of my checklist is "SIM", the current macro will also highlight "simultaneous", "similar", etc. Is there a way to avoid this?

Vazeer    21 Jul 2015, 02:39
I have a list of some 100+ words to check their presence in a PDF file. In PDF, I could import only a notepad to present the list of words to be checked, using redaction to highlight/remove the list of words. The problem with notepad is that I can't have certain terms searched. Fox example, I want to search for the following combination:
Any letter+space+however (To find out the error in a sentence like this: They knew it was useful however, they felt it was expensive.) (It should be: “… was useful; however, they felt…”)
Any number+space+respectively (To find out the error in a sentence like this: Tom and Peter spent $10 and $15 respectively, from their savings.) (It should be “… $10 and $15, respectively”)
How do I have this customized search possible? Any idea would be greatly appreciated.
Christopher Joyson    29 May 2015, 17:36

IS it possible to do similar but the other way round, I check what words are missing from the list. so it would highlight the words in checklist, or would I just swop the to round.
I would also prefer if the list is an excel one.
Zinny Simpson    28 Apr 2015, 17:19
I know this is an old thread but I have the same problem as Jack. Assuming it is due to the fact I am trying to do this on a mac version of Word. Is the script different in that case?


Satkar    25 Feb 2015, 22:44
Can you please post the macro for word2014 and later? It's not working for word 2010 or 2013. Please help!!!
Darrell    12 Feb 2015, 14:41

Thank you for posting your update. Since I know very little about VBA, can you post a complete macro that I could just copy and paste into Word to have this word-searching macro work for compound search terms? Many thanks again!
Peter    26 Aug 2014, 11:45
Dear all,

I was also looking for a solution to the compound words problem Darrell reported:

* Cong Thang's .IgnoreSpace solution did not work for me
* I found the solution on this forum: http://www.tech-archive.net/Archive/Word/microsoft.public.word.vba.general/2007-11/msg00613.html
The problem is that the macro selects the words from the documents as words, not paragraphs; forum commenter Jay Freedman explained what you can change to the script to solve this problem:

Dim wrdRef As String
Dim wrdPara As Paragraph
For Each wrdPara In docRef.Paragraphs
wrdRef = wrdPara.Range.Text
' remove the paragraph mark:
wrdRef = Left(wrdRef, Len(wrdRef) - 1)
If Asc(Left(wrdRef, 1)) > 32 Then
With Selection.Find
.Wrap = wdFindContinue
.Text = wrdRef
.Execute Replace:=wdReplaceAll
End With
End If
Next wrdPara

When I implemented this, the macro performed perfectly, but ran into a problem at the end of the list.
This problem can be solved by moving the If clause one line up:

For Each wrdPara In docRef.Paragraphs
wrdRef = wrdPara.Range.Text
If Asc(Left(wrdRef, 1)) > 32 Then
' remove the paragraph mark:
wrdRef = Left(wrdRef, Len(wrdRef) - 1)
With Selection.Find
.Wrap = wdFindContinue
.Text = wrdRef
.Execute Replace:=wdReplaceAll
End With
End If
Next wrdPara

Dear M. Wyatt, thanks a lot for this very useful macro!
Fightergator    18 Jun 2014, 20:45
I know this is an old posting, but hoping someone still checking it. I got your macro to run and just highlight the words I'm searching for. However, I'm trying to include some words with Wildcards in my list of search words, with WildCard = True, but I get a "< is not a valid special character" when I try to run it. Any ideas? I'm doing technical editing for the Air Force. I'm also interested in a macro to search and replace from a list. If you have this info in one of your books, I'd be happy to purchase.

cong Thang    10 Aug 2013, 03:59
Just need to add .IgnoreSpace = True
Susan Schuster    08 May 2013, 14:12
Is there a way to list out in a new document, the words that are found,rather than highlighting them?
Darrell    15 Feb 2013, 11:17
What is the syntax of the file name you're accessing? It works fine with the path I used:

sCheckDoc = "D:Documents and SettingsuserDesktopChecklist.docx"
Jack    24 Oct 2012, 23:42
I'm trying to use this macro on my MBP with Mountain Lion and Microsoft 2011, but I keep getting the same error message:

"Run-time error '5174':

This file could not be found.
Try one or more of the following:
*Check the spelling of the name of the document.
*Try a different file name.

I guess I'm entering the file path wrong, but i've tried every variation I can think of. Please help!!!
Darrell    01 Nov 2011, 14:45
Works great on finding single words, but how do I get the macro to find word combinations (like "ice cream")? Putting the term in quotes only causes the macro to search for quotes!

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.