Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2017, 06:23 AM
gmayor's Avatar
gmayor gmayor is offline Change Color (Being provided between the two codes) Windows 10 Change Color (Being provided between the two codes) Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Color (Being provided between the two codes) Spellchecker Macro Provided by MVP Not Checking for Grammar PSSMargaret Word VBA 2 06-09-2016 04:02 AM
Change Color (Being provided between the two codes) RGB color codes? regwitt Excel Programming 2 01-06-2015 04:51 PM
Change Color (Being provided between the two codes) Color codes as background Anderso Excel 1 12-19-2014 11:53 PM
Converting color codes in VBA Ulodesk Word VBA 7 11-24-2014 04:15 AM
Change Color (Being provided between the two codes) Codes for Word Textbox Font Color? tinfanide Word VBA 7 10-23-2012 03:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft