We help IT Professionals succeed at work.

Change Text Color

NiceMan331
NiceMan331 asked
on
125 Views
Last Modified: 2017-07-31
Hi
i have word document consist of around 100 pages
i would like to change the text color by code based on existing text color
for example :
if text color = red , change it to blue
if blue , change it to black

and also , to format specific texts has blue color to be italic
... etc

how i can do it
Comment
Watch Question

JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
RaminTechnical Advisor
CERTIFIED EXPERT

Commented:
You need a Macro.
Paul SauvéRetired
CERTIFIED EXPERT

Commented:
no matter what you select as a solution, be sure to change the blue to black BEFORE changing the red to blue, otherwise you will end up with black through the entire document (unless of course, that is the result you want)

Author

Commented:
I need a code or macro to change it , not manually plz
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Colleen Kayter4D Assets
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
RaminTechnical Advisor
CERTIFIED EXPERT

Commented:
This is a simple VBA code to convert all Red fonts in your file to Italic blue, you can change the color font depending on your need.

Sub ChangeColorWithReplace()   
    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorRed
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    Selection.Find.Replacement.Font.Italic = True
With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Open in new window

Technical Advisor
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Colleen Kayter4D Assets

Commented:
NiceMan331, you've asked 175 questions and have only accepted 3 answers. Could you offer us some feedback on the comments provided?