S
Stevie_mac
Trying to get data from SQL Server (MSDE) database with Excel 97
The 1st part fails with ...
Runtime error 1004
Application-defined or object-defined error
'Create external data range
Set objMyQueryTable = ActiveSheet.QueryTables.Add( _
Connection:="OLEDB;Provider=SQLOLEDB.1;User ID=sa;Initial Catalog=MyData;Data Source=localhost", _
Destination:=Range("a1")) **** Fails On This Line ****
'Retrieve data
With objMyQueryTable
.CommandText = "Select * From MyData"
.CommandType = xlCmdSQL
.Name = "MyData"
.Refresh False
End With
I know the connection string is good - I set up a udl file with the same Connection String
I can get this to work with DSN and URL Connection Strings but not OLEDB
Any clues? (PS, using a DSN is not an option since this will be opened on lots of different machines)
Or any other suggestions getting data from MSDE into excel
The 1st part fails with ...
Runtime error 1004
Application-defined or object-defined error
'Create external data range
Set objMyQueryTable = ActiveSheet.QueryTables.Add( _
Connection:="OLEDB;Provider=SQLOLEDB.1;User ID=sa;Initial Catalog=MyData;Data Source=localhost", _
Destination:=Range("a1")) **** Fails On This Line ****
'Retrieve data
With objMyQueryTable
.CommandText = "Select * From MyData"
.CommandType = xlCmdSQL
.Name = "MyData"
.Refresh False
End With
I know the connection string is good - I set up a udl file with the same Connection String
I can get this to work with DSN and URL Connection Strings but not OLEDB
Any clues? (PS, using a DSN is not an option since this will be opened on lots of different machines)
Or any other suggestions getting data from MSDE into excel