View Single Post
 
Old 11-11-2015, 02:53 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Tbl As Table, Rng As Range, strTxt As String, i As Long, j As Long
Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument
  For Each Tbl In .Tables
    With Tbl
      For i = 1 To .Rows.Count
        Set Rng = .Cell(i, 2).Range
        With .Cell(i, 1).Range
          For j = 1 To .Words.Count
            strTxt = Trim(.Words(j))
            With Rng.Find
              .ClearFormatting
              .Text = strTxt
              With .Replacement
                .ClearFormatting
                .Highlight = True
                .Text = "^&"
              End With
              .Format = True
              .Forward = True
              .MatchCase = False
              .MatchWholeWord = True
              .MatchWildcards = False
              .Wrap = wdFindStop
              .Execute Replace:=wdReplaceAll
            End With
          Next
        End With
      Next
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
Note that the above code searches for everything VBA regards as a 'word'. That includes punctuation.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote