View Single Post
 
Old 06-24-2020, 02:30 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

If you are going to pass drive-by questions at least show some effort to post structured code and declare your variables.


Code:
Option Explicit
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
Dim oDoc As Document
Dim oRng As Range
Dim arrFind
  Set oDoc = ActiveDocument
  arrFind = Array(". ,", "house")
  For lngIndex = 0 To UBound(arrFind)
    Set oRng = oDoc.Range
    With oRng.Find
      .Text = arrFind(lngIndex)
      .Format = True
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      Do While .Execute(Forward:=True) = True: oRng.HighlightColorIndex = wdYellow: Loop
   End With
Next lngIndex
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote