My goal is to add a 'Page x of y' string in my footer. Stickler is I am
creating the whole doc in code. I have not seen a way to insert a fieldcode
programmatically. Can this be done? or is there a better way?
Hi,
simple example for header consisting of
1 paragraph only.
Inserts at the end of the paragraph.
' wdHeaderFooterPrimary = 1
Dim rTmp As Range
Set rTmp = ActiveDocument.Sections(1).Headers(1).Range
With rTmp
.InsertAfter "Page "
.Collapse direction:=wdCollapseEnd
.Fields.Add Range:=rTmp, Text:="PAGE"
.End = .Paragraphs(1).Range.End
.InsertAfter " of "
.Collapse direction:=wdCollapseEnd
.Fields.Add Range:=rTmp, Text:="NUMPAGES"
End With
I left some options out for brevity.
There might be still simpler solutions.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
howard - 11 Mar 2005 02:37 GMT
Helmut, Danke - works like a charm, just a few minor changes to run from VFP
and it works great.
Howard
> Hi,
>
[quoted text clipped - 22 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000