hello
I am trying to combine a single page of a worksheet with another worksheet and print to a file. I want page 1 to print on its own (its a summary of the other sheets), page 2 to front sheet1, page 3 to front sheet2 etc.
I have managed to select each page and each worksheet, but when I try to printout I get an error.
This is my code:
For sheetIndex = 1 To numberOfSheets - 1 Step 1
sheetName = Sheets(sheetIndex).Name
If (sheetIndex = 1) Then
sheetName = "Summary"
topSheetFileName = projectReference & projectRevision & " - " & sheetName & ".pdf"
Sheets("TS1").PrintOut from:=sheetIndex, To:=sheetIndex, printtofile:=True, prtofilename:=topSheetFileName
End If
If (sheetIndex > 1) Then
Sheets("TS1").Activate
Set topSheet = Sheets("TS1").Range(Cells((sheetIndex - 1) * n + 1, 1), Cells(sheetIndex * n, 9))
topSheet.Select
'Stop
Set calcSheet = Sheets(sheetIndex)
calcSheet.Activate
'This all works and selects
'Now if I try to print the two ranges I get an error
Sheets(Array(topSheet, calcSheet)).PrintOut
'Stop
End If
I am trying to combine a single page of a worksheet with another worksheet and print to a file. I want page 1 to print on its own (its a summary of the other sheets), page 2 to front sheet1, page 3 to front sheet2 etc.
I have managed to select each page and each worksheet, but when I try to printout I get an error.
This is my code:
For sheetIndex = 1 To numberOfSheets - 1 Step 1
sheetName = Sheets(sheetIndex).Name
If (sheetIndex = 1) Then
sheetName = "Summary"
topSheetFileName = projectReference & projectRevision & " - " & sheetName & ".pdf"
Sheets("TS1").PrintOut from:=sheetIndex, To:=sheetIndex, printtofile:=True, prtofilename:=topSheetFileName
End If
If (sheetIndex > 1) Then
Sheets("TS1").Activate
Set topSheet = Sheets("TS1").Range(Cells((sheetIndex - 1) * n + 1, 1), Cells(sheetIndex * n, 9))
topSheet.Select
'Stop
Set calcSheet = Sheets(sheetIndex)
calcSheet.Activate
'This all works and selects
'Now if I try to print the two ranges I get an error
Sheets(Array(topSheet, calcSheet)).PrintOut
'Stop
End If