Avatar of NiceMan331
NiceMan331
 asked on

Change Text Color

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
Microsoft Word

Avatar of undefined
Last Comment
Colleen Kayter

8/22/2022 - Mon
Jeff

SOLUTION
John

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Ramin

You need a Macro.
Paul Sauvé

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)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
NiceMan331

ASKER
I need a code or macro to change it , not manually plz
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ramin

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

ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Colleen Kayter

NiceMan331, you've asked 175 questions and have only accepted 3 answers. Could you offer us some feedback on the comments provided?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.