Link to home
Start Free TrialLog in
Avatar of dabeachboy
dabeachboy

asked on

Adding "Page X of Y" auto text to a page footer

Hi there, I'm new around here.  Hope someone can offer some help with this question.

I'm developing a Word 2000 automation program using Visual FoxPro 6.0, and a little nagging problem I haven't solved yet is inserting the auto text "Page X of Y" into the page footer of the document. Anyone know the easiest way to do this?
Avatar of xSinbad
xSinbad

This is some code I have used to write to word headers it should help you out.


  If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
      ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
       = wdMasterView Then
      ActiveWindow.ActivePane.View.Type = wdPageView
  End If
 
  ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
  Selection.WholeStory
  Selection = strHeader
  ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ASKER CERTIFIED SOLUTION
Avatar of xSinbad
xSinbad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dabeachboy

ASKER

Hey xSinbad,

Thanks a bunch for posting your sample.  I still needed to make a couple of tweaks and translate it into VFP language but it definitely helped me get on the right track.

For your notes in case anyone needs to do something similar:

1) 'wdPageView' should have been 'wdPrintView' -- unless of course the constants are named differently in different versions of Word.  What do I know, right?  I've only been writing Word automation programs for about a week.  Search for it in the Object Browser.

2) The "Page X of Y" auto-text should be added as follows:

NormalTemplate.AutoTextEntries("Page X of Y").Insert Where := Selection. _
Range

Thanks again!