How advanced is the "replace" function in Word 2000?

T

Ted Shoemaker

Hello,

I have a long *.doc file in Word 2000. I would like to locate all the
places in that document which use red text, and insert the word "Robin"
there. Is there an easy way to do this? I don't want to slog through
the document myself, line by line. In case it helps, I'm interested
here only in the standard red color, not in the millions of custom colors.

And let's generalize that question. The "replace" function is set up to
replace text, ignoring font, placement, etc. Suppose I want to change
all occurrences of something without considering the verbal content of
the text itself (e.g. I'm looking for all uses of a certain font, color,
location on the page, etc). Is there a way of manipulating this?

Probably I'm looking for something other than the "replace" function.

Thank you for all help.

Ted Shoemaker
 
A

Anne Troy

This (recorded) macro finds the first red-text character in the doc, backs
up a space, inserts "SomeWordHere".

If you wanted to do this continuously, you'll have to get the code
re-worked.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded July 8, 2005 by Anne Troy
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^?"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="SomeWordHere "
End Sub
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com
 
J

Jay Freedman

Hi Anne,

There's a bug in the recorder that makes it fail to record the kind of
formatting you're searching for. After the .Text line you need to insert

.Font.Color = wdColorRed

to make it look for red text. This is one of several bugs I wrote about in
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.

The macro would also need a loop inserted around the .Execute and .TypeText
lines to make it find all the occurrences. There would have to be a tricky
little bit at the end of that loop that moves the Selection to a point after
the red text, so it doesn't keep finding the same red text over and over.
 
K

Klaus Linke

Hi Ted,

Probably you have discovered by now that you can find red text by going into
"Format > Font" in the "Edit > Replace" dialog?
You can just leave the "Find what" text empty if you want to search some
formatting.

If you want to replace the red text with the text "Robin", you put "Robin"
in "Replace with". You can apply some other color (say, "automatic") at the
same time, again by choosing that in "Format > Font" while the cursor is in
"Replace with".

If you want to add "Robin" in front of any red text, you'd put "Robin^&" in
"Replace with".
^& will insert the found text. You don't have to remember the placeholder
^&: It's listed among other text when you click on the "Special" button.

Searching for some font would work the same. Searching for a certain
location on the page isn't so simple, but you can search for special
formatting or special characters that determine the location (say "page
break before" in the paragraph format, or manual page breaks, column breaks,
line breaks, ...), or you can limit your search to specific regions (say
footnotes or comments).

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