Excel is what's known as an ActiveXEXE Server and is designed to instantiate
multiple instances of 'itself' for multi-workbook usage. However, this means
that - by design - it will persist even after all references to it have been
destroyed.
Usually this is because the code failed or because the code 'forgot' to
close the application instance before releasing the reference.
This is one of the many reasons that Excel, Word etc. are frowned upon for
web server instantiated usage - it can leave multiple copies divorced in the
system without means to kill them (apart from a reboot that is).
Chris.
[quoted text, click to view] "CST" <cont@b-50.com> wrote in message
news:038501c3aae4$6bdce550$a101280a@phx.gbl...
Hi All,
I have run into a strange occurrence. Basically I want
to open up an Excel file and do a save as to html (I know
office automation on server is bad). I wrote a small com
application to do this. Please see the code below:
Option Explicit
Public Function XLSTest(XLSFileName As String)
Dim oXLSApp As Excel.Application
Dim oXLSWB As Excel.Workbook
Dim strXLSFile As String, strFullPath As String
Set oXLSApp = CreateObject("Excel.Application")
oXLSApp.Visible = True
oXLSApp.AskToUpdateLinks = False
oXLSApp.DisplayAlerts = False
strFullPath = "C:\Temp\"
strXLSFile = "C:\Temp\" & XLSFileName & ".xls"
Set oXLSWB = oXLSApp.Workbooks.Open
(FileName:=strXLSFile)
ActiveWorkbook.SaveAs FileName:=strFullPath &
XLSFileName, _
FileFormat:=xlHtml, ReadOnlyRecommended:=False,
CreateBackup:=False
oXLSWB.Close False
Set oXLSWB = Nothing
oXLSApp.Quit
Set oXLSApp = Nothing
End Function
This com object is called from an asp page:
<%
' *** Objects ***
Dim oRpt
Dim strFile, strPath
strFile = "Test"
Set oRpt = Server.CreateObject("XLSRun.XLSTest")
oRpt.XLSTest(strFile)
set oRpt = Nothing
%>
Everything works as expected (the html file(s) are
created), but the strange thing is the instance of Excel
is never destroyed. If you open up task manager and run
the asp page you will see the instance of Excel.exe
running. When the program finishes, I thought that it
would kill that instance of Excel, but it doesn't. Why
won't that instance of Excel go away. I believe that I
am destroying all of the references to Excel in my VB
code. Am I doing something obviously wrong? Please
help..
I am using VB6 (ActiveX dll) and running IIS 5.0.
TIA