I need to recolour text for a selected portion of a word document but omitting the recolor if the text is found in a table. Here's what I have so far:
With workrange.Find
.ClearFormatting
.Text = "SearchText"
Do While .Execute
If Not workrange.Information(wdWithInTable) Then
workrange.Font.Color = RGB(255, 0, 0)
End If
Loop
End With
The recolouring starts at the beginning of my selected area and text in tables is ignored. All OK. But the problem is that the loop continues beyond the end of my original selected area to the end of the document, recoloring every subsequent instance of the text string not in a table.
I've probably missed something simple - what is it?
With workrange.Find
.ClearFormatting
.Text = "SearchText"
Do While .Execute
If Not workrange.Information(wdWithInTable) Then
workrange.Font.Color = RGB(255, 0, 0)
End If
Loop
End With
The recolouring starts at the beginning of my selected area and text in tables is ignored. All OK. But the problem is that the loop continues beyond the end of my original selected area to the end of the document, recoloring every subsequent instance of the text string not in a table.
I've probably missed something simple - what is it?