RE: Replace footer text by SteveC
SteveC
Thu Jan 24 09:39:08 PST 2008
Lene,
Thanks so much for the help! It is much appreciated.
--
Steve C
"Lene Fredborg" wrote:
> You will find a macro (function) below that should do the job. Some comments
> first:
>
> 1. Three different footers exist: first page footer, primary footer, even
> page footer. In the macro, I have assumed your footer is a "primary footer" â??
> it is if the document does not have "Different first page" and "Different odd
> and even" turned on in File > Page Setup > Layout tab.
>
> 2. In a document with more than one section, the macro will only replace
> text in the footer of section 1.
>
> 3. The function has a parameter, sReplacement. When calling the function,
> sReplacement must be set to the value of ProjNum (supposed to be a string).
> You can use the following line of code to call the function:
>
> ReplaceTextInFooter sReplacement:=ProjNum
>
> This will execute the function below. The function can be placed in any
> module.
>
> Function ReplaceTextInFooter(sReplacement As String)
> Dim oRange As Range
>
> Set oRange =
> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
> With oRange.Find
> .Text = "<Project #>"
> .Replacement.Text = sReplacement
> .Execute Replace:=wdReplaceAll
> End With
>
> Set oRange = Nothing
> End Function
>
> --
> Regards
> Lene Fredborg
> DocTools - Denmark
> www.thedoctools.com
> Document automation - add-ins, macros and templates for Microsoft Word
>
>
> "Steve C" wrote:
>
> > I need my code to be able to search a footer section for the text "<Project
> > #>" in a multiple page, single section document and replace it with the value
> > of a variable (ProjNum) provided from a user form. Can someone help me out?
> > Thanks!
> > --
> > Steve C