Connections.Add method (Excel)
Adds a new connection to the workbook.
Syntax
expression.Add (Name, Description, ConnectionString, CommandText, lCmdtype, CreateModelConnection, ImportRelationships)
expression A variable that represents a Connections object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Name | Required | String | Name of the connection. |
Description | Required | String | Brief description about the connection. |
ConnectionString | Required | Variant | The connection string. |
CommandText | Required | Variant | The command text to create the connection. |
lCmdtype | Optional | XlCmdType | Command type. |
CreateModelConnection | Optional | Boolean | Specifies whether to create a connection to the PowerPivot model. |
ImportRelationships | Optional | Boolean | Specifies whether to import any existing relationships. |
Return value
WorkbookConnection
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.