I'm trying to create a macro so that when it's applied it will highlight specific words from a list of words I have. I've got the macro started however I can't seem to figure out how to keep it from highlighting words within words. For example, I want it to highlight the word
in, which it will do, but it also highlights it in the word
involved and be
ing. Any help, or recommendation for an alternate macro is appreciated. I know I ran across something like this once before but am having difficulty relocating it. This is what I have so far:
Code:
Sub ListChange()
Dim r As Range
Dim MyList() As String
Dim i As Long
MyList = Split("additionally,ah,almost,big,can be,could,could be,generally speaking,he,in,it,it is,low,many,may,might,most,plenty,she,should,some,these,they,this is,we,with", ",")
For i = 0 To UBound(MyList())
Set r = ActiveDocument.Range
With r.Find
.Text = MyList(i)
.Replacement.Highlight = wdYellow
.Execute Replace:=wdReplaceAll
.MatchWildcards = False
.MatchWholeWord = True
.MatchAllWordForms = False
End With
Next
End Sub