Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Pages....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
howard - 10 Mar 2005 03:23 GMT
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?
Helmut Weber - 10 Mar 2005 10:26 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.