Solved

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

Posted on 2002-05-02
3
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Outlook Free & Paid Tools
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
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…

726 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