View Single Post
 
Old 05-06-2021, 03:54 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Well, if you wanted the hit highlight - as shown in the dialogue box you posted a screenshot of, you should have said so. And, as per my previous reply, even the macro recorder would give you the code for that.

Somewhat more sophisticated:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String
StrFnd = InputBox("What is the text to highlight?")
If Trim(StrFnd) = "" Then Exit Sub
With ActiveDocument.Range.Find
  .ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = False
  .HitHighlight StrFnd, Options.DefaultHighlightColorIndex
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]