Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Matching if not a particular color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LtCommander - 13 Jan 2006 01:36 GMT
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
LtCommander - 13 Jan 2006 01:48 GMT
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...
Greg Maxey - 13 Jan 2006 02:17 GMT
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?

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> 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...
LtCommander - 13 Jan 2006 04:04 GMT
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
Greg Maxey - 13 Jan 2006 04:29 GMT
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.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Greg,
>
[quoted text clipped - 12 lines]
>
> Vince
LtCommander - 13 Jan 2006 04:56 GMT
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
Klaus Linke - 13 Jan 2006 05:10 GMT
> 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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.