Thanks Macropod! Your code fixed the infinite loop issue for that function and similar ones. The macro seems to run faster too.
However, I'm not sure how to convert other infinite-loop-prone functions that only replace parts of strings to your suggested format. For example:
Code:
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[0-9]%-[0-9]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.MatchWholeWord = False
.Execute
End With
Do While oRng.Find.Found = True
oRng.Characters(2).Text = ""
oRng.Collapse Direction:=wdCollapseEnd
oRng.Find.Execute
Loop
Is there a simple way to do that? Many thanks.