QueryTables.Add Connection Parameter

N

Nirmal Singh

I am trying to connect to an existing Excel 97 spreadsheet.

I have found the following connection strings from www.connectionstrings.com/. I have tried both
versions (seperately) and I get the same error message 1004: application-defined or object-defined
error.

I have been able to use this method to connect to an external Oracle database using ODBC.

Is there something wrong with my coonection string? BTW ThisSheet is declared as Excel.Worksheet
and definitely exists.


ThisSheet.QueryTables.add Connection:="Driver={Microsoft Excel Driver
(*.xls)};DriverId=790;Dbq=D:\MonthlyStatsMaster.xls;DefaultDir=D:\;", _
' Destination:=ThisSheet.Range("A1"), Sql:="Select * from [Hierarchy$]"

ThisSheet.QueryTables.add Connection:="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\MonthlyStatsMaster.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""", _
Destination:=ThisSheet.Range("A1"), Sql:="Select * from [Hierarchy$]"




Nirmal Singh
 

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