Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel .....

Status
Not open for further replies.

RaceAap

IS-IT--Management
Sep 5, 2001
39
NL
Hi,

I need to open an excel sheet with ole db.. but when the sheet has a comment on A1 I get an error that the object could not be found...

I use the following code to open the sheet:

strExcelString = "Data Source=" & strExcelFile & "; Extended Properties=Excel 8.0;"

Set conExcelFile = CreateObject("ADODB.Connection")
With conExcelFile
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = strExcelString
.CursorLocation = adUseClient
.Open
End With

Set rstExcel = CreateObject("ADODB.Recordset")

Set rsT = conExcelFile.OpenSchema(adSchemaTables)

intTblCnt = rsT.RecordCount
For t = 1 To intTblCnt

strTbl = rsT.Fields("TABLE_NAME").Value
tbl(t) = Replace(strTbl, "'", "")
'Response.Write( &quot;Sheet: &quot; & strTbl & &quot;<br>&quot;)
rsT.MoveNext
Next

'Need to make the spreadsheet selection automatic.
strExcelStatement = &quot;select * from [&quot; & tbl(1) & &quot;] &quot;
'Response.Write(strExcelStatement)
With rstExcel
Set .ActiveConnection = conExcelFile
.Open strExcelStatement
End With

At .Open strExcelStatement I get the error...
Who can help me??

When I open the file and remove the comment from A1 I can read the file, but I need to be able to open the file whithout editing as it is an automated process....

Thanx
Lon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top