Select words with specific attributes/color

H

Hari Prasadh

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
 
H

Hari Prasadh

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.
 
H

Helmut Weber

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/
 

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