Name

pivotcache.LocalConnection [= setting]

Synopsis

For OLAP pivot caches, True uses a local cube file and False uses a remote OLAP provider. Default is False. The following code saves an OLAP pivot table as a local cube file, then uses that data source offline:

Sub UseOLAPOffline(  )
    Dim pc As PivotCache, pt As PivotTable, fname As String
    ' Run earlier example to create pivot table.
    CreateOLAPPivotTable
    ' Get pivot table.
    Set pt = ActiveSheet.PivotTables(1)
    ' Get the pivot cache.
    Set pc = pt.PivotCache
    ' Save local cube file.
    fname = ActiveWorkbook.Path & "\" & pt.Name & ".cub"
    pt.CreateCubeFile fname
    ' Take cache offline.
    pc.LocalConnection = "OLEDB;Provider=MSOLAP;Data Source=" & fname
    pc.UseLocalConnection = True
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.