Solved

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

Posted on 2002-05-02
3
248 Views
Last Modified: 2009-12-16
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?
0
Comment
Question by:dabeachboy
  • 2
3 Comments
 
LVL 6

Expert Comment

by:xSinbad
ID: 6987814
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
0
 
LVL 6

Accepted Solution

by:
xSinbad earned 50 total points
ID: 6987822
Sorry you need to change the header bits to footer bits. 8->

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 = wdSeekCurrentPageFooter
 Selection.WholeStory
 Selection = "Page x"
 ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
0
 

Author Comment

by:dabeachboy
ID: 6989420
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!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This article will show you how to use shortcut menus in the Access run-time environment.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question