Solved

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

Posted on 2002-05-02
3
250 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

My experience with Windows 10 over a one year period and suggestions for smooth operation
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

733 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