Page Number in cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello I created a purchase order template. I need to show the number of
pages of the purchase order, but not in a header or footer.
Example Cell F10 is " No. Pages" (means the no of pages for the purchase
order) cell G11 should automatically populate number of pages ( 2, 3 or
how many papges there are for the order.)
How can I do this? thanks
 
Sub Pages_In_Cell()
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
ActiveSheet.Range("G11") = TotPages
ActiveSheet.PrintOut
End Sub

Or event code in Thisworkbook module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
ActiveSheet.Range("G11") = TotPages
ActiveSheet.PrintOut
End Sub


Gord Dibben MS Excel MVP
 
Is there a way to do this, but instead of referencing total pages, to
reference the page number of a specific page/sheet from the work book (so say
I switch the position of the sheet from the last page to the third page, how
to I make sure that the cell will track that change).

Ben
 
None that I know of but hang around.

One of the more knowledgeable types may come up with something.


Gord

On Wed, 16 Jul 2008 13:18:16 -0700, Ben Langhammer <Ben
 
Back
Top