Change Text Color

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnBusiness Consultant (Owner)Commented:
You would have to select the sections you want changed and make those sections a specific Style. Then you can change the colour of the Style or Font. Once done, this gives you most flexibility for current and later changes.

OR,  Select blocks of text using the Ctrl Key along with Select to select multiple blocks and set the colour each time you do this.
RaminTechnical AdvisorCommented:
You need a Macro.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Paul SauvéRetiredCommented:
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)
NiceMan331Author Commented:
I need a code or macro to change it , not manually plz
Shaun VermaakTechnical SpecialistCommented:
Just use Find and Replace but instead of typing text to find, you select font colour
Colleen Kayter4D AssetsCommented:
Shaun is right and Paul has an excellent point. Make a list of the changes you want to make. If any of the current states are to be results for other text, make those changes first (e.g., the blue becomes black before the red becomes blue).

If you think you might need to do all these same formatting tricks on other documents, record a macro as you go through the search and destroy process.

Out of curiosity, are the current font colors the result of someone else reviewing the doc? All the red and blue sounds like tracked changes.
RaminTechnical AdvisorCommented:
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.Font.Color = wdColorRed
    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

RaminTechnical AdvisorCommented:
This one converts red font to Italic blue and Blue to normal black.

Sub ReplaceFontColor()
    Application.ScreenUpdating = False
    Dim d As Document: Set d = ActiveDocument
    For i = 1 To d.Characters.Count
        If d.Characters(i).Font.TextColor.RGB = RGB(255, 0, 0) Then
            d.Characters(i).Font.TextColor.RGB = RGB(0, 0, 255)
            d.Characters(i).Font.Italic = True
              If d.Characters(i).Font.TextColor.RGB = RGB(0, 0, 255) Then
                 d.Characters(i).Font.TextColor.RGB = RGB(0, 0, 0)
              End If
        End If
      Application.ScreenUpdating = True
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Colleen Kayter4D AssetsCommented:
NiceMan331, you've asked 175 questions and have only accepted 3 answers. Could you offer us some feedback on the comments provided?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.