View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
James Cornthwaite James Cornthwaite is offline
external usenet poster
 
Posts: 53
Default One print job as oposed to several ?

Bob, sorry to be a pain, but i'm new to VB and hate using things I dont
understand.

I have just read the code and am unsure how the tf boolean is significant.
Why can't this just be true everytime rather than just the first iteration.
(far from saying its wrong, just i dont understand !)

Also what does "curr.select" at the end of the code do/mean??

Thanks again
James



"James Cornthwaite" wrote in message
...
i'll give it a go and report back.

many thanks
James


"Bob Umlas, Excel MVP" wrote
in message ...
Try this:
Sub PrintAllSheets()
Dim tf As Boolean, TheSheet As Worksheet, Curr As Worksheet
tf = True
Set Curr = ActiveSheet
For Each TheSheet In Worksheets
If LCase(TheSheet.Name) = "client details" Or LCase(TheSheet.Name)
=
"import" Then
Else
TheSheet.Select tf
tf = False
End If
Next
ActiveWindow.SelectedSheets.PrintOut
Curr.Select
End Sub


"James Cornthwaite" wrote:

I have (with help) written the following macro.

It essentially prints the first page of every worksheet in a workbook

with the exception the "import" and "client details worksheets".


My problem is this macro code causes each page to be sent to the printer
as
a seperate job.
This wouldn't be a problem but i'm in a busy office (and though quick)
other
printouts will sneak in between the pages.

Is there any coding variation which would lead to only one job being
sent to
the printer.


Many thanks in anctipation.

James


Sub PrintFullAccounts()

Dim theSheet As Worksheet

For Each theSheet In ActiveWorkbook.Worksheets
If theSheet.Name = "import" Or theSheet.Name = "client details"
Then
'do nothing
Else
'print first page
theSheet.PrintOut From:=1, To:=1, Copies:=1
End If

Next theSheet

End Sub