Please ammend or adivise re this easy print rountine

  • Thread starter Thread starter James Cornthwaite
  • Start date Start date
J

James Cornthwaite

I'm fairly new to writing macros (only used JAVA before not VB). Please help


I want to write a macro to print all worksheets (first page for each only)
in a workbook

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


I have made the following guess of how it should be written.

Please advise where I've gone wrong.
I don't know how to refer to the end of all worksheets in range or
how to refer to a worksheet name (guessed with application.name)

Many many thanks in anticipation

James


Sub Printing()
'
' Printing Macro


For i = 1 To ??end of all worksheets??

Sheets(i).Select

If (ActiveWindow.SelectedSheets.Application.Name = "import") Or
(ActiveWindow.SelectedSheets.Application.Name = "client details") Then
' do nothing
Else
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1,
Copies:=1, Collate:=True
End If

Next i

End Sub
 
Try this James

Sub Printing()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets

If sh.Name = "import" Or sh.Name = "client details" Then
' do nothing
Else
sh.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
End If

Next sh

End Sub
 
brilliant, thanks !


Ron de Bruin said:
Try this James

Sub Printing()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets

If sh.Name = "import" Or sh.Name = "client details" Then
' do nothing
Else
sh.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
End If

Next sh

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

Back
Top