I am using the following standard bit of code to loop through the worksheets and lock each pivot table's structure.
The code is breaking at (1), and I believe it may be because I have a few calculated fields. Any help is appreciated.
Code:
Sub LockPivotTable()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws as Worksheet
For Each ws in ActiveWorkbook.Worksheets
Set pt = ActiveSheet.PivotTables(1)
With pt
.EnableWizard = False
.EnableDrilldown = False
.EnableFieldList = False
.EnableFieldDialog = False
.PivotCache.EnableRefresh = True
For Each pf In pt.PivotFields
With pf
.DragToPage = False '(1)
.DragToRow = False
.DragToColumn = False
.DragToData = False
.DragToHide = False
End With
Next pf
End With
Next ws
End Sub