Why??Originally Posted by brettdj
(I love looping)
No really, regular expressions is the way to go.
So brilliant coding!![]()
For all the other "Loop lovers" on off the many other possibillities but now with a loop (Just "Yoinking" you...learned it today..)[VBA]
Sub GetTheFox()
MarkIt "fox"
End Sub
Sub MarkIt(sFind As String)
Dim oWord As Word.Range
Dim iCnt As Integer
For Each oWord In ActiveDocument.Range.Words
If Trim(oWord.Text) = sFind Then
iCnt = iCnt + 1
If iCnt = 10 Then
With ActiveDocument.Range(Start:=oWord.Start, End:=oWord.End - 1)
.Bold = True
.Underline = True
End With
Exit For
End If
End If
Next oWord
End Sub
[/VBA]
See Yah!