saving xls as html
Posted by Bryce Winter on December 27, 2001 8:41 AM
I need to open an xls file using the application object and save the xls workbook as an xlHTML file. I am having trouble with the syntax for the .SaveAs method. As this can not be run in a macro, I think the syntax is a little different. Here's what I have so far.
Function saveAsHTML()
Dim objXLApp
Dim objXLBook
'create excel application object
set objXLApp = CreateObject("Excel.Application")
If IsObject(objXLApp) Then
'we have an application object. continue with translation
msgBox("Created object successfully. Ready to create workbook object.")
'open the workbook specified on uploadReport in the session("filename") var
set objXLBook = objXLApp.Workbooks.Open("<%=strFile%>")
If IsObject(objXLBook) Then
msgBox("Opened workbook object successfully. Ready to open file.")
'we have the workbook object. continue with translation
objXLBook.SaveAs("test4.htm", xlHtml)
objXLBook.Close 'Close the workbook
set objXLBook = nothing 'destroy excel wkbk object
Else
msgBox("There was an error creating the workbook object.")
End If
set objXLApp = nothing 'destroy excel app object
Else
'there was an error creating the excel application object
msgBox("Could not create Excel Application Object.")
set objXLApp = nothing 'manually destroy app object just in case.
End If
End Function
Everything goes as planned until I hit the saveas line. Any suggestions?