View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default How can I get the number of a printed page for use in a cell?

Take a look at this page at Ozgrid:
http://www.ozgrid.com/VBA/printed-pages.htm
I found that the first routine:

Sub PrintedPages()
MsgBox ExecuteExcel4Macro("Get.Document(50)")
End Sub

seems to work properly, while the second Sub returned 42 for a sheet that
the routine above returned 29 for. 29 was the correct answer as verified in
print preview. OOPS - subsequent runs also returned 42, which is not correct
but is understandable: the sheet is 14 pages long, divided into 3 sections:
A:E, F:R and then just S and T. BUT the area containing S and T is only 1
sheet 'long' so the answer should be 14 x 2 + 1 = 29, but it's being
calculated as 14 * 3 =42.

The result the code returns could be usable if your sheet is one page wide,
or if it is several sheets wide, all are of the same length. But getting the
results to you in a way you can use could be interesting.

If you want to pursue it, I'm willing to play with it some - or someone
who's already been down this road may come along and give us THE answer.



"Mark F" wrote:

How can I get the number for a printed page for use in a
cell?

I want to make a table of contents that has the page
number that the first page of each sheet when it is
printed.

The number of pages for each sheet varies depending
on the page length used, so I don't see how to get
the page numbers unless do a Print Preview, look at the
page numbers in the print footers, and then edit the
table of contents page.

Is there a function to get the page that a cell prints
on in the print preview? This would allow me to do a Print
Preview and have the page number be inserted on each reference
page, which I then could use in the contents page.

Thank you.