Looping through worksheets in an Excel (xls) file using classic ASP on a win 2008 server
- by Roy
Hi,
I have just migrated an older ASP solution to a windows 2008 server and everything works out fine except for using ADOX.Catalog to list all the worksheets in an uploaded xls file. I use the following code:
<%
Set objExcelCon = Server.CreateObject("ADODB.Connection")
With objExcelCon
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & strFilePath & "\" & strFileName & ";Extended Properties=Excel 12.0;"
.Open
End With
Set objAdo = Server.CreateObject("ADOX.Catalog")
' Set ADOX activeConnection
objAdo.activeConnection = objExcelCon
' Loop through tables (worksheets)
For i = 0 To objAdo.Tables.Count - 1
response.Write objAdo.Tables(i).Name
Next
Set objExcelCon = Nothing
Set objAdo = Nothing
%
When I run this i get no error message or anything. Anyone got any idea whats causing this?
Best regards,
Roy