PivotCache.SourceConnectionFile property (Excel)

Returns or sets a String indicating the Microsoft Office Data Connection file or similar file that was used to create the PivotTable. Read/write.

Syntax

expression.SourceConnectionFile

expression A variable that represents a PivotCache object.

Example

This example determines if a connection exists for the PivotTable cache, and if there is a connection, displays the file name. If no connection exists, the code handles the run-time error and notifies the user. This example assumes that a PivotTable exists on the active worksheet.

Sub CheckSourceConnection() 
 
 Dim pvtCache As PivotCache 
 
 Set pvtCache = Application.ActiveWorkbook.PivotCaches.Item(1) 
 
 On Error GoTo No_Connection 
 
 MsgBox "The source connection is: " & pvtCache.SourceConnectionFile 
 Exit Sub 
 
No_Connection: 
 MsgBox "PivotCache source can not be determined." 
 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.