Print only the last page

  • Thread starter Thread starter beeawwb
  • Start date Start date
B

beeawwb

Good afternoon all.

This should be really simple, but I can't seem to find the righ
property to do it.

I'm using VBA to try and get only the last page in my workbook t
print. I have a long list, and every time I start a new day, I insert
page break. So, when I print, I only want to print today's data, tha
being the last page.

So, I have a button to replace the "Print" button. And when I print it
I want it to do

ActiveWorkbook.PrintOut(LastPage, LastPage)

The problem is, I can't figure out how to count the number of pages i
the active workbook. I know in a header you can use the &PAGES field
but I can't seem to find the VBA equiv.

2 ways I've thought of is, something that automatically has the las
page as a number or a variable (called LastPage) that counts the numbe
of total pages in the workbook.

Any solutions?

Thanks. :)

-Bo
 
Hi
to get the last page number you may use the following line of code:
last_page = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
 
Thanks for that! I used Franks solution, and then tried the MsgBo
Sheets(Sheets.Count).Name solution to see what it would do. It gave th
variable as "Sheet1" where it should have returned 11. (That was usin
LastPage = Sheets(Sheets.Count).Name
MsgBox returned a syntax error?

Anyway, thanks for the help.

-Bo
 
Back
Top