printing a different (hidden) sheet

I

ibmerlin

I am trying to place a print button on one sheet and have that butto
print a different (hidden) sheet. The button seems to always b
printing the sheet that the button is on.
Also I need to get the number of pages to be printed from the sheet th
button is on. But seeing that I have yet to get the proper page t
print I have not worried about that yet.

Thank you for any help
ibmerli
 
R

Ron de Bruin

Hi ibmerlin

You must unhide the sheet before you can print it
Try this macro

Sub test()
Application.ScreenUpdating = False
With Sheets("Sheet2")
.Visible = True
.PrintOut
.Visible = False
End With
Application.ScreenUpdating = True
End Sub

Sub test2()
' pages Activesheet
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
MsgBox TotPages
End Sub
 

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