Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Recursion / Iteration in Word 2013 Mail Merge 16 50
excel formula 6 26
Excel 2007 problem 2 27
Check version 13 61
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now