Olá Amigos!
Encontrei uma solução
Eu tive que referenciar com o seguinte código:
For Each wks In ActiveWorkbook.Worksheets
For Each pt In wks.PivotTables
.....código
Next pt
Next wks
código menor:
Sub Trava1()
Dim pt As PivotTable
Dim wks As Worksheet
Dim pf As PivotField
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
For Each pt In wks.PivotTables
For Each pf In pt.PivotFields
pf.EnableItemSelection = False
Next pf
Next pt
Next wks
End Sub
E o Código maior:
Sub Trava2()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
For Each pt In wks.PivotTables
With ActiveSheet.PivotTables(1)
pt.EnableWizard = False
pt.EnableDrilldown = False
pt.EnableFieldList = False
pt.EnableFieldDialog = False
pt.PivotCache.EnableRefresh = False
For Each pf In .PivotFields
With pf
.DragToPage = False
.DragToRow = False
.DragToColumn = False
.DragToData = False
.DragToHide = False
End With
Next pf
End With
Next pt
Next wks
End Sub
Espero que isso possa ajudar alguém no futuro.
Postado : 27/04/2018 5:46 am