Share via


WorkbookBase.PivotCaches Method

Definition

Gets a PivotCaches collection that represents all the PivotTable caches in the specified workbook.

public:
 Microsoft::Office::Interop::Excel::PivotCaches ^ PivotCaches();
public Microsoft.Office.Interop.Excel.PivotCaches PivotCaches ();
member this.PivotCaches : unit -> Microsoft.Office.Interop.Excel.PivotCaches
Public Function PivotCaches () As PivotCaches

Returns

A PivotCaches collection that represents all the PivotTable caches in the specified workbook.

Examples

The following code example uses the PivotCaches method to set each Microsoft.Office.Interop.Excel.PivotCache in the current workbook to update automatically each time the workbook is opened.

This example is for a document-level customization.

private void WorkbookPivotCaches()
{
    Excel.PivotCaches caches = this.PivotCaches();

    if (caches != null)
    {
        for (int i = 1; i < caches.Count; i++)
        {
            caches[i].RefreshOnFileOpen = true;
        }
    }
}
Private Sub WorkbookPivotCaches()
    Dim caches As Excel.PivotCaches = Me.PivotCaches()

    If Not (caches Is Nothing) Then
        Dim i As Integer
        For i = 1 To caches.Count
            caches(i).RefreshOnFileOpen = True
        Next i
    End If
End Sub

Applies to