Sub highlight_test_results()
\'
\' highlight_test_results Macro by @francisluong
\' Find instances of "Test Result:" which are not highlighted and:
\' - extend selection to end of line`
\' - highlight it
\'
Dim iCount As Integer
Dim searchDone As Boolean
Dim searchTextArray(0 To 0) As String
Dim searchText As Variant
searchTextArray(0) = "Test Result:"
Options.DefaultHighlightColorIndex = wdYellow
For Each searchText In searchTextArray
Selection.HomeKey Unit:=wdStory
searchDone = False
iCount = 0
Do While searchDone = False And iCount < 1000
iCount = iCount + 1
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Text = searchText
.Highlight = False
End With
Selection.Find.Execute
If Selection.Find.Found Then
Selection.EndOf Unit:=wdLine, Extend:=wdExtend
Selection.Range.HighlightColorIndex = wdYellow
Else: searchDone = True
End If
Loop
Next searchText
End Sub