Matching if not a particular color

L

LtCommander

What I want to do is to find and replace if the text if not red in
color. I mean:

with activedocument.range.find
.text="test"
.font.color <> wdcolorred

with .replacement
..
..
..
end with

Of course, I can't say ".font.color <> wdcolorred", so is there any
possible way to match any text so long as it is not red in color?

Thanks,

Vince
 
L

LtCommander

I guess the only way to do this is to first get all the red text and do
a .font.strikethrough=true on them. Later, when searching I could do a
..font.strikethrough=false and finally switch all the stricken text to
its original non stricken self. I don't think there is any other way to
do this...
 
G

Greg Maxey

I don't know what you want to do with the found text, but perhaps:

Sub Testing()
Dim oRng As Range
Set oRng = ActiveDocument.Content

With oRng.Find
.ClearFormatting
.Text = "<*>"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
If .Font.Color = wdColorRed Then
'Do nothing
Else
MsgBox oRng
End If
End With
Loop
End With
End Sub

BTW, assuming that you are Navy, shouldn't that be LCDR?
 
L

LtCommander

Greg,

That's much more elegant than my 'strikethrough' idea! Thanks, that's
what I wanted to do.

I am a navy seal who has been awarded a purple heart for extraordinary
show of courage in a war zone. Joking! Don't salute me yet!! I have
nothing to do with the navy or any other military force! I have one of
those boring desk jobs. Why "LtCommander"? That's because I was
actually watching a JAG episode (TV series) and was inspired by
Commander Rab's (lead character) arguments. He was LCDR in the show and
LCDR (email) was already taken...

Thanks, again!

Vince
 
G

Greg Maxey

Vince,

A "Purple Heart" for courage was all it took to see through the Seal story.
;-)

I have been in the Navy for 29 years. CDR Rab sees more action in an
episode than most Navy member's see in a career (Seal's excluded of course).

Glad I could help.
 
L

LtCommander

Greg,

I should have researched 'Purple Heart' before attempting to lie!

It's suprising how so many Americans in the IT industry were actually
in the navy before. Well, after seeing the Junior Deck Officer's bed in
USS Midway (San Diego), I pretty much came to a conclusion that life in
the navy would have probably been awful!

Vince
 
K

Klaus Linke

LtCommander said:
That's much more elegant than my 'strikethrough' idea!


Your strikethrough idea might still be a lot faster. If you have many red
pieces, Word does the "Replace all" faster than if you stop at every red
text range.

Regards,
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