Font substitution from on color to another

A

aquarius79

Hello,

I wish to create a macro that will replace non only a word with anothe
but also a font color with another.
eg. I want to replace the word "apple" in black with the word "pear" i
red.

I tried to record this but the changes in font color/type/size won'
work. As I don't know anything at programming, could anyone tell me ho
I can change this macro so that the word "pear" appears in red ?

Sub apple()
'
' apple Macro
' Macro enregistrée le 19/02/2004 par Violaine
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "apple"
.Replacement.Text = "pear"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Thanks
 
K

Klaus Linke

As I don't know anything at programming, could anyone tell me how
I can change this macro so that the word "pear" appears in red ?


Hi Aquarius,

Stick the line
Selection.Find.Replacement.Font.Color = wdColorRed
right before "With Selection.Find"

The macro recorder often doesn't record stuff, or drops in stuff that
doesn't make sense in other cases.

If you only want to replace "black" text, you'd need to know if the color is
really black, or "automatic" (more probable).
Depending on that, you'd use
Selection.Find.Font.Color=wdColorBlack
or
Selection.Find.Font.Color=wdColorAutomatic
(also above "With Selection.Find").

Greetings,
Klaus
 

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