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 / December 2004

Tip: Looking for answers? Try searching our database.

Search for Font Color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dsc - 19 Dec 2004 11:10 GMT
I suspect this is blindingly obvious, but I just can't figure it out.

The Word replace dialog allows you to specify a font color and search for
text only of that color, such as every instance of the word "the" that is in
red text.

Could somebody please tell me how you do that from a macro?

Thanks for any assistance.
Shauna Kelly - 19 Dec 2004 13:51 GMT
Hi dsc

The following will find red "the"s and replace them with blue "xxx"s. If you
don't need to replace, then leave out the whole With .Replacement .... End
With section. And, just .Execute without .Execute Replace:=wdReplaceAll.

Sub FindRedThe()

   With Selection.Find
       'Clear out old stuff
       .ClearFormatting

       'Set the search string
       .Text = "the"

       'Go forward from the selection and
       'then wrap throughout the document
       .Forward = True
       .Wrap = wdFindContinue

       'Require Word to search for formatting
       .Format = True

       'Set the format to find
       .Font.Color = wdColorRed

       'Set the replacement requirements
        With .Replacement
           .ClearFormatting
           .Text = "xxx"
           .Font.Color = wdColorBlue
       End With

       'Go!
       .Execute Replace:=wdReplaceAll
   End With

End Sub

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I suspect this is blindingly obvious, but I just can't figure it out.
>
[quoted text clipped - 5 lines]
>
> Thanks for any assistance.
dsc - 21 Dec 2004 13:03 GMT
Thanks, Shauna.

Actually, while it wasn't quite the solution, it did turn on the lightbulb
finally.

I just have to go through and turn everything to be changed to one color,
then go through again searching for that color and change what needs to be
changed.

Thanks again.

> Hi dsc
>
[quoted text clipped - 50 lines]
>>
>> Thanks for any assistance.
 
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.