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 2005

Tip: Looking for answers? Try searching our database.

Select words with specific attributes/color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hari Prasadh - 21 Jan 2005 10:33 GMT
Hi,

I am used to an Excel environment (little VBA) but not MS Word.

I want to programmatically select all those words in a word document which
have the same font/format/color as below and then change them to a different
font/format/color. Is it possible?
"Starting

Its like suppose I copy a page from Web (like, I got the above from
http://cpearson.com/excel.htm )and paste in to word and then print it out,
some words which have different font color wont be visible. But such words
are spread/distributed through out the document and I dont want to do a
select all (ctrl+A) and change font color of every word. So, how do i go
about it?

Again I dont know the font color of the above word
Signature

Thanks a lot,
Hari
India

Hari Prasadh - 21 Jan 2005 13:13 GMT
Hi,

Just to add  to this, is it possible to select all instances of the word "
Sub *(" in the document.

I have actually copied somebody's Excel VBA code in to word and formatting
it so that the starting of each Sub and ending of each Sub( same for
functions) could be bold etc.

Signature

Thanks a lot,
Hari
India

> Hi,
>
[quoted text clipped - 13 lines]
>
> Again I dont know the font color of the above word
Helmut Weber - 22 Jan 2005 22:19 GMT
Hi Hari,
probably, you are looking for something like this:

Sub Makro17()
Dim rTmp As Range
Set rTmp = ActiveDocument.Range
resetsearch
With rTmp.Find
 .Text = "<Sub>"
 .MatchWildcards = True
  While .Execute
     rTmp.Select
     Selection.Bookmarks("\para").Select
     Selection.Font.Bold = True
 Wend
End With
resetsearch
End Sub

Public Sub ResetSearch()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  ' plus some more
  .Execute
End With
End Sub

Which means:

reset search options
search for "sub" as a whole word,
select the paragraph it is in,
format the selection as bold
reset search options

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Hari Prasadh - 24 Jan 2005 05:45 GMT
Hi Helmut,

Thnx a lot for your post.

Signature

Thanks a lot,
Hari
India

> Hi Hari,
> probably, you are looking for something like this:
[quoted text clipped - 48 lines]
> Word XP, Win 98
> http://word.mvps.org/ 
 
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.