Vba code to print all sheets

A

Arild

I'm trying to use this code to intercept when the user makes a print from
one of the worksheets. My objective is to print all sheets without the user
needing to select all.
This code does that - and then prints the activesheet once more - since a
normal print is performed after the code has been executed:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wk As Worksheet
For Each wk In Worksheets
wk.PrintOut
Next
End Sub

So I would be very happy if someone could point me in the right direction !
 
P

PeterS

Arild said:
I'm trying to use this code to intercept when the user makes a print from
one of the worksheets. My objective is to print all sheets without the user
needing to select all.
This code does that - and then prints the activesheet once more - since a
normal print is performed after the code has been executed:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wk As Worksheet
For Each wk In Worksheets
If wk.Name<>ActiveSheet.Name then wk.PrintOut
Next
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