Connection Property
Applies To
PivotCache object, QueryTable object.
Description
Returns or sets a string that contains one of the following: ODBC settings that enable Microsoft Excel to connect to an ODBC data source; a URL that enables Microsoft Excel to connect to a Web data source; or a file that specifies a database or Web query. Read/write String.
Remarks
Setting the Connection property doesn't immediately initiate the connection to the data source. You must use the Refresh method to make the connection and retrieve the data.
For more information about the connection string syntax, see the Add method.
Example
This example supplies new ODBC connection information for query table one.
Worksheets(1).QueryTables(1) _
.Connection:="ODBC;DSN=96SalesData;UID=Rep21;PWD=NUyHwYQI;"