Search and Replace text with multiple font color to Black font col

M

Macro''''er

Please help! I am looking for a VB code to Search and Replace color font
texts. Search the document with Green and Red texts and replace them with
Black color font text for Word 2003.

Thank you!
 
J

Jay Freedman

Please help! I am looking for a VB code to Search and Replace color font
texts. Search the document with Green and Red texts and replace them with
Black color font text for Word 2003.

Thank you!

A macro isn't really necessary -- you can do this entirely within the Replace
dialog. Click the More button to expand the dialog. With the cursor in the Find
What box, click the Format button, choose Font, choose the green font color, and
click OK. Move the cursor to the Replace With box, and this time select black
(or Automatic) font color. Click the Replace All button, which changes all the
green text to black. Repeat the process but choose red font color for the Find
What box. (It actually took me longer to write that description than it took to
do it.)

If you really want a macro, here's the equivalent code:

Sub UncolorText()
Dim myRg As Range
Set myRg = ActiveDocument.Range
With myRg.Find
' replace all green text
.Format = True
.Text = ""
.Font.Color = wdColorGreen
.Replacement.Text = ""
.Replacement.Font.Color = wdColorBlack
.Execute Replace:=wdReplaceAll

' start over at the beginning
' and replace all red text
Set myRg = ActiveDocument.Range
.Format = True
.Text = ""
.Font.Color = wdColorRed
.Replacement.Text = ""
.Replacement.Font.Color = wdColorBlack
.Execute Replace:=wdReplaceAll
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top