Find and Replace in Footer?

  • Thread starter Brian McCullough
  • Start date
B

Brian McCullough

All,

I have some VB Script that loops through each field in a record and attempts
to do a "Find and Replace" for each instance in the active document. Here
is the code:


FieldName = objField.Name
FieldValue = objField.Value & ""

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

With Selection.Find
.Text = "<<" & FieldName & ">>"
.Replacement.Text = FieldValue
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

Selection.Find.Execute Replace:=wdReplaceAll

How do I get Word to replace instances of <<FieldName>> in the Header or
Footer section of the document with the FieldValue?

Thanks!

Brian
 

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