E
eric
Guest
Comment est ce que je pourrais définir une zone d'impression qui s'adapterait à un tableau croisé dynamique. Afin de ne pas devoir toujours la redefinir??
Merci d'avance
Merci d'avance
Sub ZoneImpression_PVT_Unique()
If ActiveSheet.PivotTables.Count = 0 Then Exit Sub
ActiveSheet.PageSetup.PrintArea = ActiveSheet.PivotTables(1).TableRange2.Address
End Sub
Sub ZoneImpression_PVT_Multiple()
Dim MaPlage As Range, oPVTs As PivotTables, oPVT As PivotTable
Dim i As Integer
Set oPVTs = ActiveSheet.PivotTables
If oPVTs.Count = 0 Then Exit Sub
Set MaPlage = Nothing
For Each oPVT In oPVTs
If MaPlage Is Nothing Then
Set MaPlage = oPVT.TableRange2
Else
Set MaPlage = Union(MaPlage, oPVT.TableRange2)
End If
Next oPVT
MaPlage.Select
ActiveSheet.PageSetup.PrintArea = MaPlage.Address
ActiveSheet.PrintOut preview:=True
End Sub
sub ZoneImpression_TCDsDuClasseur
Dim MaPlage As Range, oPVTs As PivotTables, oPVT As PivotTable
Dim bValidWorksheet As Boolean
For Each wsh In ActiveWorkbook.Worksheets
Set oPVTs = wsh.PivotTables
If oPVTs.Count = 0 Then GoTo nnext:
'# pour être sur de n'imprimer que des feuilles avec PVT
'# to ensure only worksheets with pivot tables will being printed
If bValideWorksheet = False Then wsh.Select
bValideWorksheet = True
Set MaPlage = Nothing
For Each oPVT In oPVTs
If MaPlage Is Nothing Then
Set MaPlage = oPVT.TableRange2
Else
Set MaPlage = Union(MaPlage, oPVT.TableRange2)
End If
Next oPVT
wsh.PageSetup.PrintArea = MaPlage.Address
wsh.Select Replace:=False
nnext:
Next wsh
ActiveWindow.SelectedSheets.PrintOut , preview:=True
end sub