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.