ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vba code to print all sheets (https://www.excelbanter.com/excel-programming/278227-vba-code-print-all-sheets.html)

Arild

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 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 !





PeterS

Vba code to print all sheets
 
"Arild" schreef in bericht ...
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

--
PeterS


---
Peter's outgoing mail is certified 100% Virus Free. (AVG)
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 23-9-2003


All times are GMT +1. The time now is 10:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com