View Single Post
 
Old 10-16-2021, 06:03 PM
poetofpiano poetofpiano is offline Windows 10 Office 2016
Novice
 
Join Date: Sep 2015
Posts: 25
poetofpiano is on a distinguished road
Default Move Selection to First of Two Search Candidates

I have a unique case where I want to move the selection forward in a document to the first of either the next highlighted word or the next word with turquoise font color. I know both actions are individually possible with:

Code:
    Selection.Find.ClearFormatting
    Selection.Find.Highlight = True
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = True
        .MatchCase = False
    End With
    Selection.Find.Execute
Code:
    Selection.Find.ClearFormatting
    Selection.Find.Font.ColorIndex = wdTurquoise
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
But how do I make Word search for both at the same time and jump to the next instance of whichever one comes first?

Thank you!!
Reply With Quote