printing an array of worksheets
I have an excel-file with a lot of worksheets in it, and I would like to
print only a few of them (in my case: from the first sheet to a sheet named
"btw").
I have the following code (selection made manually):
Sub TestPrint()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Voorblad").Select
Sheets(Array("Voorblad", "Inhoudsopgave", "Opdracht", "res", "fin",
"liq", "balans", _
"V&W", "kosten", "Grondslagen", "vaste_act", "fin_act", "vl_act",
"liq midd", "ev", _
"pass lang", "pass kort", "btw")).Select
Sheets("Voorblad").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
But if there's a worksheet added, it will not be in the array.
And I have another code, selecting everything from the first sheet to the
sheet "btw", but it doesn't print the page-numbering allright (and with the
first code is does that allright):
Sub PrintenJaarrapport()
Dim S As Worksheet
For Each S In Worksheets
S.Select
If S.Name = "rekenblad" Then
Exit Sub
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
'Selection.PrintOut Copies:=1, Collate:=True
'ActiveWindow.SelectedSheets.PrintPreview
Next S
Worksheets("Inhoudsopgave").Activate
End Sub
Is there someone who can help me with this problem?
Thanks, Marco.
|