|
Sub PrintAllSheets()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim wb As Workbook, wb2 As Workbook, ws As Worksheet
Set wb = ThisWorkbook
arr = wb.Sheets(1).Range("a1").CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 2) = 1 Then
Set wb2 = Workbooks.Open(arr(i, 1))
With wb2
For Each ws In wb2.Sheets
If ws.Visible = xlSheetVisible Then
ws.PrintOut
End If
Next ws
End With
wb2.Close (False)
End If
Next
Set wb2 = Nothing
Set wb = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "打印完成!"
End Sub |
|