Word Replace Function

C

C Holmes

Hi

I am using Word 2003 and am trying to figure out if there is a way to
restrict the Replace functionality to only search/replace in the document
header/footer.

When the document opens up, the user is presented with a form. One of the
fields they enter into the form will be used for the Search/Replace.

Thanks in advance
 
G

Graham Mayor

Are we to understand that you are trying to replace information in a header
based on the content of the document? The simplest way to do this would be
to use a REF or STYLEREF field in the header.
If this information if from a form field, then you will need to run a macro
on exit from that field to update the REF field in the header (STYLEREF
should update itself). The update macro code is listed as the example at
http://www.gmayor.com/installing_macro.htm

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
H

Helmut Weber

Hi

Dim rngHead As Range
Set rngHead = ActiveDocument.Sections(1).Headers
(wdHeaderFooterPrimary).Range
With rngHead.Find
.Text = "kopf" ' german for head
.Replacement.Text = "fuss" ' german for foot
.Execute Replace:=wdReplaceAll
End With

To be repeated for footer.

See in addition:
http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm

and pay attention to the concept of storyranges,
the storyranges-object and sections.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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