AW: Ausgeblendete Tabellen Drucken VBA
20.11.2014 14:54:01
Rudi
Hallo,
Sub Drucken(Optional Vorschau As Boolean = False)
Dim Blaetter(), j%, i%, wks
Dim arrSheets()
ReDim arrSheets(1 To Sheets.Count, 1 To 2)
j% = 0
For i = 1 To Sheets.Count
arrSheets(i, 1) = Sheets(i).Name
arrSheets(i, 2) = Sheets(i).Visible
Next i
Set wks = ActiveSheet
For i = 0 To Me.ListBox_Tabellen.ListCount - 1
If Me.ListBox_Tabellen.Selected(i) = True Then
j = j + 1
ReDim Preserve Blaetter(1 To j)
Blaetter(j) = Me.ListBox_Tabellen.List(i, 0)
Sheets(Blaetter(j)).Visible = xlSheetVisible
End If
Next
Me.Hide
If Me.OB_Druck_gruppiert = True Then
If Vorschau = True Then
ActiveWorkbook.Sheets(Blaetter).PrintPreview
Else
ActiveWorkbook.Sheets(Blaetter).PrintOut
End If
Else
For i = LBound(Blaetter) To UBound(Blaetter)
If Vorschau = True Then
ActiveWorkbook.Sheets(Blaetter(i)).PrintPreview
Else
ActiveWorkbook.Sheets(Blaetter(i)).PrintOut
End If
Next i
End If
wks.Select
For i = 1 To UBound(arrSheets)
Sheets(arrSheets(i, 1)).Visible = arrSheets(i, 2)
Next
End Sub
Gruß
Rudi