返回或设置创建数据透视表的 Microsoft Office 数据连接文件或类似的文件。String 类型,可读写。
expression.SourceConnectionFile
expression 必需。该表达式返回“应用于”列表中的对象之一。
本示例确定是否存在与数据透视表缓存相连的连接,如果存在,则显示该文件的名称。如果不存在连接,则代码将处理运行错误,并通知用户。本示例假定数据透视表位于活动工作表上。
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