add page n of m text to footer

E

Eric

The following code puts the page number in the footer easy enough, but how
do you do something like "Page N of M"?

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add(wdAlignPageNumberLeft)
 
C

Charles Kenyon

If you don't need to do it with code, it is easy. There is an AutoText entry
on the menu on the Header/footer toolbar to do it.

The method you are using will cause editing problems. In my documents it
inserts a frame with margins such that the page number can't even be seen.

Otherwise, you insert a page field and a numpages field in the header or
footer where you want it.

The following works if normal.dot is the attached template (and has its
native AutoText).

Sub InsertPageXofY()
'
' Macro written 10/14/2005 by Charles Kyle Kenyon
'
Dim rFooter As Range
Set rFooter =
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
ActiveDocument.AttachedTemplate.AutoTextEntries("Page X of Y").Insert _
Where:=rFooter, RichText:=True
End Sub

I create templates that have the headers/footers and other structures I want
and simply create documents based on them. It is a lot simpler than using
code. http://addbalance.com/usersguide/templates.htm

BTW the term is Page X of Y, at least around here.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
E

Eric

X of Y. Got it!

What do you mean by "native AutoText" ? I'm curious because my office 2003
installation at home has no autotext entries, while here at work they are
all available. What's the difference?

Eric
 
C

Charles Kenyon

The difference is that at home, you overwrote your normal.dot template. See
http://www.mvps.org/word/FAQs/AppErrors/BlankDocNotBlank.htm.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies and questions to
the newsgroup so that others can learn from my ignorance and your wisdom.
 
C

Charles Kenyon

By "native AutoText" I mean the AutoText entries that come built into
normal.dot as created by Word.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
E

Eric

great, thanks.

Charles Kenyon said:
By "native AutoText" I mean the AutoText entries that come built into
normal.dot as created by Word.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top