Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Insert total page numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jens - 10 Jun 2005 10:51 GMT
I want to add the page number an the total numbers of pages in the header.
I use this syntax to add to pagenumber:
           
.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add(PageNumberAlignment:=wdAlignPageNumberRight, FirstPage:=False)

but can't figure out how the add total number of pages.
Like page 1 of 12

Thx
Jens
Jonathan West - 10 Jun 2005 12:56 GMT
>I want to add the page number an the total numbers of pages in the header.
> I use this syntax to add to pagenumber:
[quoted text clipped - 7 lines]
> Thx
> Jens

Use a NUMPAGES field

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Jens - 10 Jun 2005 15:02 GMT
> Use a NUMPAGES field

Jonathan

In the past I used early binding to word8, but now some clients with XP
machines and many different language versions, I started get problems, and
what I understand from several newsgroups, that late binding is more flexible
in this kind of scenario.
In the past I used this code:
.Selection.Fields.Add(Range:=.Selection.Range, Type:=wdFieldNumPages)

Could you be kind and show me a sample code how to use NUMPAGES?

Jens
Jonathan West - 10 Jun 2005 16:15 GMT
>> Use a NUMPAGES field
>>
[quoted text clipped - 9 lines]
>
> Could you be kind and show me a sample code how to use NUMPAGES?

You don't need to use code at all. If you include a NUMPAGES field in the
template, it will automatically update to show the total number of pages in
any document based on the template.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Jens - 10 Jun 2005 16:51 GMT
> You don't need to use code at all. If you include a NUMPAGES field in the
> template, it will automatically update to show the total number of pages in
> any document based on the template.
>
>--
I am not able to use a special designed template with a pre inserted field,
as users are spread all over the world, with an unknown numbers of formats
and versions. So I can only use the local Normal.dot template, and start from
schratch.
Regards
Jens
Jonathan West - 10 Jun 2005 17:02 GMT
>> You don't need to use code at all. If you include a NUMPAGES field in the
>> template, it will automatically update to show the total number of pages
[quoted text clipped - 10 lines]
> Regards
> Jens

OK, If you are using late binding, then the only change you need make to the
line of code you had before is to substitute the value of wdFieldNumPages
for the constant itself. This constant has the value 26.

By the way, I would be very surprised if it really is impossible to
distribute a template as part of your application. Since you have no idea
what kinds of mess users may have made of their normal.dot, distributing
yourown template would probably increase the stability of your application

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.