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( "Sheet: " & strTbl & "<br>"
rsT.MoveNext
Next
'Need to make the spreadsheet selection automatic.
strExcelStatement = "select * from [" & tbl(1) & "] "
'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
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( "Sheet: " & strTbl & "<br>"
rsT.MoveNext
Next
'Need to make the spreadsheet selection automatic.
strExcelStatement = "select * from [" & tbl(1) & "] "
'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