Muokkaa

Jaa


WorkbookConnection object (Excel)

A connection is a set of information needed to obtain data from an external data source other than a Microsoft Excel workbook.

Remarks

Store connections in an Excel workbook

Connections can be stored within an Excel workbook. When the workbook is opened, Excel creates an in-memory copy of the connection that is referred to as the connection object. A connection object contains information such as the name of the server and the name of the object to be opened on that server.

Optionally, the connection object may also include authentication credentials and/or a command that is to be passed to the server and executed (example: a SELECT statement to be executed by SQL Server).

Note

The exact form of the connection depends on the mechanism that is being used to retrieve data; ODBC connections, OLEDB connections, and web queries will contain different information.

Store connections in a connection file

A connection may also be stored in a separate connection file. Most connections in an Excel workbook include a pointer to an external connection file. Connection files have extensions that clearly label them as connection files (*.ODC, *.IQY, etc.) and may be located on the user's local machine or in other well-known or trusted locations such as WSS (Data Connection Library), or other corporate servers.

Connection files enable multiple users within the same organization to re-use connections. Network administrators are able to change the way the entire organization connects to a back-end data source by changing a single connection file. A connection file is not always required when connecting to an external data source.

Identify connections

Connection names are strings that uniquely identify connections within the workbook in which they are used. There are other properties of a connection that are not unique. Whenever a formula in Excel takes an argument that is a connection, it will be sufficient to refer to the name of that connection, either directly (as a string) or indirectly (by referring to a cell that contains the connection name as a string).

Methods

Properties

See also

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.