Need a macro to reset page count

D

Dennis

Hello, I have a word template that has a fax page appended
to the end of the document. Sometimes the user prints the
document to fax, so they have 3 pages and the page of
pagecount is correct, 2 of 3, 3 of 3. Sometimes they
print the document and throw away the fax sheet, hence the
pagecount appears incorrect, 2 of 3, 3 of 3 when there are
only using 2 pages. I like to create a macro to reset the
pagecount to pagecount -1. Not real versed in VB, but
I'll give it a whirl.

we are using word 2002.
 
C

Cindy Meister -WordMVP-

Hi Dennis,

Please describe how and where the page count is being
generated? { PAGE } of { NumPages }, I'd guess? Any way to
uniquely identify it in the text? (Bookmark; specific table
cell; header/footer...?)
Hello, I have a word template that has a fax page appended
to the end of the document. Sometimes the user prints the
document to fax, so they have 3 pages and the page of
pagecount is correct, 2 of 3, 3 of 3. Sometimes they
print the document and throw away the fax sheet, hence the
pagecount appears incorrect, 2 of 3, 3 of 3 when there are
only using 2 pages. I like to create a macro to reset the
pagecount to pagecount -1. Not real versed in VB, but
I'll give it a whirl.

we are using word 2002.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
D

Dennis

Hi Cindy,
It appears to be an inserted auto text "Page X of Y" in
the header. No bookmarks or field name that I can tell.
Thanks Dennis
 
C

Cindy Meister -WordMVP-

Hi Dennis,
It appears to be an inserted auto text "Page X of Y" in
the header. No bookmarks or field name that I can tell.
See if this line of code in your macro does the trick:

ActiveDocument.Sections(1).Headers( _
wdHeaderFooterPrimary).Range.Fields.Update

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
D

Dennis

Do I need to do anything to reset the page number and page
count prior to the update? If so, how?
 
L

Lars-Eric Gisslén

Dennis,

Why not ask the user if the cover page should be printed or not when they
want to print?
If thet dont want to use the cover sheet and you remove it, the page numbers
should be correct.

Perhaps this code could be a starting point.
'------------------------------------------
Sub FilePrint()
DoPrint
End Sub
'------------------------------------------
Sub FilePrintDefault()
DoPrint
End Sub
'------------------------------------------
Sub DoPrint()
Dim nReply As Long
Dim oDLG As Dialog

nReply = MsgBox("Do you want to print the cover sheet?", _
vbYesNo, "Print Fax")

If nReply = vbNo Then
Selection.GoTo what:=wdGoToPage, _
Which:=wdGoToAbsolute, Count:=1
ActiveDocument.Bookmarks("\Page").Select
Selection.Delete
End If

Set oDLG = Dialogs(wdDialogFilePrint)
oDLG.Display

End Sub
'------------------------------------------

Regards,
Lars-Eric
 
L

Lars-Eric Gisslén

Dennis,

Right after printing you could close the document with
Activedocument.Close SaveChanges:=wdDoNotSaveChanges

The field {NUMPAGES} shows the total number of pages in the document, while
the field {SECTIONPAGES} displays the number of pages in the section. If the
document has two sections, one for the document to send and one for the
cover sheet you could use SECTIONPAGES in the document and NUMPAGES in the
cover sheet to display the total number of pages including the cover sheet.
Just an idea.

We have been using this technique in a document template where several
chapters are added (for a bioplasma company where documentation is very
strict). Each chapter has to restart page numbering at 1 and show how many
pages there are in each chapter plus the total number of pages of the whole
document.

Regards,
Lars-Eric
 
D

Dennis

Thanks for the info, I'll try that.
-----Original Message-----
Dennis,

Right after printing you could close the document with
Activedocument.Close SaveChanges:=wdDoNotSaveChanges

The field {NUMPAGES} shows the total number of pages in the document, while
the field {SECTIONPAGES} displays the number of pages in the section. If the
document has two sections, one for the document to send and one for the
cover sheet you could use SECTIONPAGES in the document and NUMPAGES in the
cover sheet to display the total number of pages including the cover sheet.
Just an idea.

We have been using this technique in a document template where several
chapters are added (for a bioplasma company where documentation is very
strict). Each chapter has to restart page numbering at 1 and show how many
pages there are in each chapter plus the total number of pages of the whole
document.

Regards,
Lars-Eric




.
 

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