Syntax

expression.IsConnected

expression A variable that represents 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 that a PivotTable exists on the active worksheet.

Visual Basic for Applications
Sub CheckIsConnected() ' Handle run-time error if external source is not OLE DB. 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 OLE DB data source." End Sub 

See also: