I want to highlight certain strings (from a list) throughout a whole word document.
Easiest option seems to be find/replace. However, if the string I am looking for contains revision marks, then (probably due to some word bug) inside hyperlinks the following things will happen:
if the 1st character of the string is marked as a revision, the string won't be found at all
if any other character of the string is marked as deleted revision, the string will be found, but won't be completely selected. Instead the selection will be for the number of characters shorter that are marked as being deleted (for example if in 'strring' the 3rd character is marked as being a deleted revision, a search for 'string' will return the selection 'strin').
My second approach was to identify the terms by preceding the search string with a wildchard character (so as to find even those terms whose 1st character has been revisioned) and subsequently expand the selection to a whole word.
Dim strTerm as String
strTerm = "string"
Selection.Find.Execute FindText:="^?" & strTerm, _
MatchCase:=False, MatchWholeWord:=False, _
MatchAllWordForms:=False, Forward:=True, _
Wrap:=wdFindStop, Format:=False
If Selection.Find.Found Then
Selection.MoveStart Count:=1 'exclude wildchart character from found string
Selection.Expand 'expand selection to whole word
end if
This will reliably find all terms, but if the term includes the 1st or last word inside a hyperlink, no matter what I do, I can not select it, I will always end up selecting the whole hyperlink field.
I need to leave the text intact with all revision marks unaltered. I can only add highlights.
Can anybody set me on the right track?