Mitchell Walker
Mitchell Walker

Reputation: 211

With ActiveWorkbook.Connections("connection"). _ OLEDBConnection

This keeps saying subscript out of range. Anyone know why?

(The "connection" is just something that I put there so I didn't enter in my own connection)

Upvotes: 0

Views: 3010

Answers (1)

Andy G
Andy G

Reputation: 19367

I don't believe the underscore should be there.

Try listing the connection-names to ensure that you have supplied it exactly

Dim conn As WorkbookConnection
For Each conn In ActiveWorkbook.Connections
    Debug.Print conn.Name
Next conn

If there is only one connection you could use Connections(1), although it is preferable to use the name.

Upvotes: 1

Related Questions