![]() |
Vba code to print all sheets ?
I'm trying to use this code to intercept when the user makes a print from
one of the worksheets. My objective is to auto 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 ! |
Vba code to print all sheets ?
Add this to the end of the routine.
Cancel = True -- Robin Hammond www.enhanceddatasystems.com Check out our XspandXL add-in "Arild" wrote in message ... I'm trying to use this code to intercept when the user makes a print from one of the worksheets. My objective is to auto 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 ! |
Vba code to print all sheets ?
Additional info:
instead of looping thru the sheets you could use the printout method of the WORKBOOK as in NOTE pagenumbering in headers/footers will be continuous (same as in activewindow.selectedsheets.printout) Private Sub Workbook_BeforePrint(Cancel As Boolean) ThisWorkbook.Printout Cancel=true End Sub keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Robin Hammond" wrote: Add this to the end of the routine. Cancel = True |
All times are GMT +1. The time now is 08:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com