Hi All,
My requirement: Certain words should not appear in our company publications such as Vice versa, &, in-built, and ad hoc.
What I have done so far: I have created a table with just one Colum (in a word doc, of course!), and typed all the offending words. Then I executed the following macro:
Code:
Sub Highlighting()
Dim oChanges As Document, oDoc As Document
Dim oTable As Table
Dim oRng As Range
Dim rFindText As Range
Dim i As Long
Dim sFname As String
sFname = "location of the file"
Set oDoc = ActiveDocument
Set oChanges = Documents.Open(FileName:=sFname, Visible:=False)
Set oTable = oChanges.Tables(1)
For i = 1 To oTable.Rows.Count
Set oRng = oDoc.Range
Set rFindText = oTable.Cell(i, 1).Range
rFindText.End = rFindText.End - 1
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(FindText:=rFindText, _
MatchWholeWord:=True) = True
oRng.HighlightColorIndex = wdBrightGreen
Loop
End With
Next i
oChanges.Close wdDoNotSaveChanges
End Sub
My Requirement: To an extent, the above macro helped me. However, I am unable to easily eliminate offending phrases such as “It is recommended”. If I use quotation marks, macro is unable to find the phrase; if I don’t use the quotes, then macro is searching for all the words (it, is, and recommended).
Can someone help me tweak this macro?
Thanks in advance,
Streetcat