IsConnected Property

Microsoft Excel Visual Basic

property is True and the PivotTable cache is currently connected to its source. Returns False if it is not currently connected to its source. Read-only Boolean.

expression.IsConnected

expression    Required. An expression that returns a PivotCache object.

Remarks

The IsConnected property does not check to see if the connection is connected. Even if this property returns True, sending commands to the provider could result in an error if the connection is no longer valid.

Requires that the cache source type is external and that it is an OLE DB data source.

Example

The following example determines if the cache is connected to its source and notifies the user. This example assumes a PivotTable exists on the active worksheet.

Sub CheckIsConnected()

    ' Handle run-time error if external source is not an OLEDB.
    On Error GoTo Not_OLEDB

    ' Check connection setting and notify the user accordingly.
    If Application.ActiveWorkbook.PivotCaches.Item(1).IsConnected = True Then
        MsgBox "The PivotCache is currently connected to its source."
    Else
        MsgBox "The PivotCache is not currently connected to its source."
    End If
    Exit Sub

Not_OLEDB:
    MsgBox "The data source is not an OLEDB data source."

End Sub