I am writing a macro( late binding) that runs through a word document and highlight all the values that is contained in my cell range in Excel. I have used the find function which works fine until I add the argument IgnoreSpace:= True, which I don't understand why it's resulting in error. Appreciate any help
VBA Code:
Sub Highlight()
Dim lrow As Long
lrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
Dim myRange As Object
Dim FindText As Object
Set myRange = ActiveDocument.Content
For i = 1 To lrow Step 1
myRange.Find.Execute FindText:=Sheet1.Range("A" & i).Value, MatchCase:=False, _
IgnoreSpace:=True, Forward:=True, MatchWholeWord:=True
If myRange.Find.Found = True Then myRange.HighlightColorIndex = wdYellow
Next i
End Sub