View Single Post
 
Old 11-03-2013, 07:36 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

You could use something like:
Code:
Sub ConditionalHighlight()
Application.ScreenUpdating = False
Dim vFindText As Variant, StrWrds As String, i As Long
vFindText = "Note,Notes"
vFindText = Split(vFindText, ",")
StrWrds = ",The,Each,"
For i = LBound(vFindText) To UBound(vFindText)
  With ActiveDocument.Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Format = False
      .MatchWildcards = True
      .Wrap = wdFindStop
      .Text = "<[! ]{1,}> " & vFindText(i) & ">"
      .Replacement.Text = ""
      .Execute
   End With
    Do While .Find.Found
      If InStr(StrWrds, "," & Trim(.Duplicate.Words.First.Text) & ",") > 0 Then
        .Duplicate.HighlightColorIndex = wdBrightGreen
      End If
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
Next i
Application.ScreenUpdating = True
End Sub
where 'StrWrds' contains the list of words that must precede the words of interest. Note that you'll need to input the singular and plural forms of each word of interest.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote