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.

Signature
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
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.
> 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)
Eric - 17 Oct 2005 14:51 GMT
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
> 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.
[quoted text clipped - 28 lines]
>>
>> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add(wdAlignPageNumberLeft)
Charles Kenyon - 17 Oct 2005 15:05 GMT
The difference is that at home, you overwrote your normal.dot template. See
http://www.mvps.org/word/FAQs/AppErrors/BlankDocNotBlank.htm.

Signature
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
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.
>X of Y. Got it!
>
[quoted text clipped - 38 lines]
>>>
>>> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add(wdAlignPageNumberLeft)
Charles Kenyon - 17 Oct 2005 15:06 GMT
By "native AutoText" I mean the AutoText entries that come built into
normal.dot as created by Word.

Signature
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
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.
>X of Y. Got it!
>
[quoted text clipped - 38 lines]
>>>
>>> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add(wdAlignPageNumberLeft)
Eric - 17 Oct 2005 16:08 GMT
great, thanks.
> By "native AutoText" I mean the AutoText entries that come built into
> normal.dot as created by Word.
[quoted text clipped - 40 lines]
>>>>
>>>> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add(wdAlignPageNumberLeft)