View Single Post
 
Old 01-27-2015, 03:05 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 Highlighting()
Application.ScreenUpdating = False
Dim oChanges As Document, oDoc As Document
Dim oTable As Table, oRng As Range, i As Long
Dim rFindText As Range, sFname As String, HiLite As Long
HiLite = Options.DefaultHighlightColorIndex
Options.DefaultHighlightColorIndex = wdBrightGreen
sFname = "location of the file"
Set oDoc = ActiveDocument
Set oChanges = Documents.Open(FileName:=sFname, Visible:=False)
Set oTable = oChanges.Tables(1)
With oDoc.Range.Find
  .ClearFormatting
  .Format = True
  .Forward = True
  .Wrap = wdFindContinue
  .MatchWholeWord = True
  With .Replacement
    .ClearFormatting
    .Highlight = True
    .Text = "^&"
  End With
  For i = 1 To oTable.Rows.Count
    Set oRng = oTable.Rows(i).Cells(1).Range
    With oRng
      .End = .End - 1
      rFindText = .Text
    End With
    .Text = rFindText
    .Execute Replace:=wdReplaceAll
  Next
End With
Options.DefaultHighlightColorIndex = HiLite
oChanges.Close wdDoNotSaveChanges
Application.ScreenUpdating = True
End Sub
PS: When posting code, please use the code tags, inserted via the # button on the toolbar.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote