An implementation of Visual Basic that is built into Microsoft products.
Set the Find formatting to font size 12 before executing the loop, instead of setting Selection.Find.Font.Size inside the loop. For example:
Sub BarrierDrawColoured()
First4 "( 1)"
First4 "( 2)"
First4 "( 3)"
First4 "( 4)"
End Sub
Sub First4(sText As String)
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Text = sText
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' Only find text that has font size 12
.Font.Size = 12
Do While .Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Bold = True
Selection.Font.Color = wdColorRed
Selection.Range.HighlightColorIndex = wdYellow
Selection.Collapse Direction:=wdCollapseEnd
Loop
End With
End Sub
Key change: .Font.Size = 12 is applied to the Find object (With Selection.Find) before Do While .Execute, so only occurrences in 12‑point text are found and processed. The line Selection.Find.Font.Size = 12 inside the loop is removed because it does not affect which text is found.
References: