Name
querytable
.Connection [= setting
]
Synopsis
Sets or returns the data source for the query table. For web queries, this is the Connection
argument used to create the query. Getting or setting this property causes an error if the query table is created from a recordset (QueryType
property is xlADORecordset
or xlDAORecordset
).
The following code displays the Connection
property for each query table on the active worksheet:
Dim qt As QueryTable For Each qt In ActiveSheet.QueryTables Select Case qt.QueryType Case xlADORecordset, xlDAORecordset Debug.Print qt.Name, qt.Recordset.Source Case Else ' Includes Web queries. Debug.Print qt.Name, qt.Connection End Select Next
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.