PivotCache.SourceDataFile property (Excel)
Returns a String value that indicates the source data file for the cache of the PivotTable.
Syntax
expression.SourceDataFile
expression A variable that represents a PivotCache object.
Remarks
For file-based data sources (for example, Access), the SourceDataFile property contains a fully qualified path to the source data file. It's set to Null for server-based data sources (such as SQL Server). The SourceDataFile property is set to Null if the Connection property is changed programmatically.
Example
This example determines if a connection exists for the cache, and if there is a connection, displays the data source 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 data source connection is: " & _
pvtCache.SourceDataFile
Exit Sub
No_Connection:
MsgBox "PivotCache source cannot 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.