Returns a String indicating the source data file for the cache of the PivotTable.
expression.SourceDataFile
expression Required. An expression that returns a PivotCache object.
SourceDataFile property as it applies to the QueryTable object.
Returns or sets a String indicating the source data file for a query table.
expression.SourceDataFile
expression Required. An expression that returns a QueryTable object.
Remarks
For file-based data sources (e.g. Access) the SourceDataFile property contains a fully qualified path to the source data file. It is null for server-based data sources (e.g. 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 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