Thread: [Solved] Highlight words from a list
View Single Post
 
Old 09-05-2018, 07:13 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your macro isn't far off being correct. Try:
Code:
Sub ListChange()
Application.ScreenUpdating = False
Dim MyList() As String, i As Long
Options.DefaultHighlightColorIndex = wdYellow
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", ",")
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Replacement.Highlight = True
  .Replacement.Text = "^&"
  .MatchWholeWord = True
  For i = 0 To UBound(MyList())
    .Text = MyList(i)
    .Execute Replace:=wdReplaceAll
  Next
End With
Application.ScreenUpdating = True
End Sub
Do note that you'll also get word forms ending with 's highlighted, but the 's won't be highlighted.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote