Option Explicit
Dim wksHid()
Sub Sheets_Printout()
Dim _
wks As Worksheet, _
i As Integer, _
bolSaved As Boolean
ReDim wksHid(0)
'// Set a flag to the workbook's current saved status. //
bolSaved = ThisWorkbook.Saved
'// Kill updating, eliminates screen "flicker" and speeds up processing //
Application.ScreenUpdating = False
'// This presumes that the hidden sheets are very xlSheetVeryHidden. //
'// Loop thru sheets, building an array of hidden sheets' names, while //
'// setting their print area and printing ea //
For Each wks In ThisWorkbook.Worksheets
With wks
If .Visible = xlSheetVeryHidden Then
wksHid(UBound(wksHid)) = .Name
.Visible = xlSheetVisible
.PageSetup.PrintArea = _
.Range("A1:I" & .Cells(Rows.Count, "I").End(xlUp).Row).Address
'// Optional: if wanting to print ALL of the invoices*******//
.PrintOut '//
'//*********************************************************//
ReDim Preserve wksHid(UBound(wksHid) + 1)
End If
End With
Next
'// Delete the last element of the array, as it will be empty //
ReDim Preserve wksHid(UBound(wksHid) - 1)
'// Optional: If .Printout was used above to print all invoices, then //
'// we can loop thru our array of sheet names to re-hide the formerly //
'//hidden sheets. If .PrintOut was not used, move this to a seperate //
'// Sub. //
For i = LBound(wksHid()) To UBound(wksHid()) '//
ThisWorkbook.Worksheets(wksHid(i)).Visible = xlSheetVeryHidden '//
Next '//
'//*********************************************************************//
'// turn updating back on //
Application.ScreenUpdating = True
'// Use flag to ignore the unhiding/hiding sheets if workbook was in a //
'// saved = True status before //
ThisWorkbook.Saved = bolSaved
End Sub