View Single Post
  #4   Report Post  
Graham Mayor
 
Posts: n/a
Default

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
Word MVP web site http://word.mvps.org


Adrian wrote:
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
Word MVP web site http://word.mvps.org


Adrian wrote:
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.