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,213
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
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
  .MatchCase = True
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .HitHighlight StrFnd, Options.DefaultHighlightColorIndex
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]