View Single Post
 
Old 05-15-2017, 06:23 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following macro should do the trick

Code:
Sub Macro1()
Const CodeA As String = "AAAA"
Const CodeB As String = "BBBB"
Dim oRng As Range

    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeA & "*" & CodeB, MatchWildcards:=True)
            oRng.Font.ColorIndex = wdRed
            oRng.Collapse 0
        Loop
    End With
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeA)
            oRng.Font.ColorIndex = wdAuto
            oRng.Collapse 0
        Loop
    End With
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeB)
            oRng.Font.ColorIndex = wdAuto
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote