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
NiceMan331Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

JeffCommented:
0
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.
0
RaminTechnical AdvisorCommented:
You need a Macro.
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

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)
0
NiceMan331Author Commented:
I need a code or macro to change it , not manually plz
0
Shaun VermaakTechnical Specialist IVCommented:
Just use Find and Replace but instead of typing text to find, you select font colour
http://somup.com/cbf3qFVVl9
0
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.
0
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.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

0
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
            DoEvents
        
        Else
              If d.Characters(i).Font.TextColor.RGB = RGB(0, 0, 255) Then
                 d.Characters(i).Font.TextColor.RGB = RGB(0, 0, 0)
                 DoEvents
                
              End If
        End If
        
      Application.ScreenUpdating = True
        
    Next
    
End Sub

Open in new window

0

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?
0
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.