Use macro to find in text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've recorded a macro in Word 2000 using Find All as this finds text in a
text box but when I run the macro, the text is not found. There seems to be
no Find All option for the Find or Execute commands.
 
There is a problem with the macro recorder and the search command. What is
it that you are trying to find?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
I am trying to find by Style Name and replace text in the stated style with
replacement text.
This is to populate a template with data. Cannot use mail merge fields as I
want header information at the top of the page and repeating information from
a datasheet, which would populate text in character styles in a document
table.
Hence, if data [Record ID] would populate the first found character style
called "Record ID".
The problem is there's no wdFindAll option !
 
You need something like:

Sub ReplaceExample()

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Style = "Record ID"
.Replacement.Text = "Your text here"
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
I am trying to find by Style Name and replace text in the stated
style with replacement text.
This is to populate a template with data. Cannot use mail merge
fields as I want header information at the top of the page and
repeating information from a datasheet, which would populate text in
character styles in a document table.
Hence, if data [Record ID] would populate the first found character
style called "Record ID".
The problem is there's no wdFindAll option !
There is a problem with the macro recorder and the search command.
What is it that you are trying to find?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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

Back
Top