Problems creating Workbook Connection programatically

M

MB34

Why do I get a "Runtime error 5. Invalid procedure call or argument" error
with the code below?
We're trying to create our connections programatically.
This is called in the Workbook_Open event.


Sub CreateNewConnection()
Dim objConn As WorkbookConnection
Dim connstr As String
Dim cmdText As String

connstr = "ODBC;DRIVER={Advantage StreamlineSQL
ODBC};DataDirectory=C:\GC\JOSH;SERVER=OurDBServer; _

CharSet=ANSI;DefaultType=Advantage;Rows=False;AdvantageLocking=ON;Locking=Record; _

MemoBlockSize=64;MaxTableCloseCache=5;ServerTypes=6;TrimTrailingSpaces=False"
cmdText = "userglobals"


Set objConn = ThisWorkbook.Connections.Add( _
Name:="MyConnection", _
Description:="Description", _
ConnectionString:=connstr, _
CommandText:=cmdText, _
lCmdType:=xlCmdTable)

objConn.Refresh
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top