Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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 !


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default 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

!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A macro code to print multiple sheets in different w.books Gladiator Excel Discussion (Misc queries) 3 February 22nd 10 07:49 PM
How do I print sheets in Excel without blank sheets after page Peggy New Users to Excel 2 January 12th 08 11:10 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
i made one spreadsheet but when i try to print two sheets print, yokhan Excel Discussion (Misc queries) 1 August 14th 05 09:24 AM
Vba code to print all sheets Arild Excel Programming 1 September 30th 03 12:19 PM


All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"