S
Simon C
I have an Access database - it uses the following code to open Excel
Public Sub OpenXlSheet(strReportName As String)
' Check if excel is open, close it if it is
If AppInUse("xlmain") <> 0 Then
Dim objExcel As Excel.Application
Set objExcel = GetObject(, "Excel.Application")
objExcel.Quit
Set objExcel = Nothing
Do While AppInUse("xlmain") <> 0
Loop
End If
'open a fresh excel application and load strReportName
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = True
objExcel.Workbooks.Open strReportName, , True
Set objExcel = Nothing
End Sub
The excel sheet opened is then closed from a userform with the
Application.Quit command
Everything appears to work corectly but it leaves an EXCEL.EXE process
behind and the next time I try and run excel from Access it gets caught
in that loop recognising that theres an excel app running but unable to
close it
Any ideas why this happens or how I get rid of the rogue process?
Thanks in advance
Simon
Public Sub OpenXlSheet(strReportName As String)
' Check if excel is open, close it if it is
If AppInUse("xlmain") <> 0 Then
Dim objExcel As Excel.Application
Set objExcel = GetObject(, "Excel.Application")
objExcel.Quit
Set objExcel = Nothing
Do While AppInUse("xlmain") <> 0
Loop
End If
'open a fresh excel application and load strReportName
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = True
objExcel.Workbooks.Open strReportName, , True
Set objExcel = Nothing
End Sub
The excel sheet opened is then closed from a userform with the
Application.Quit command
Everything appears to work corectly but it leaves an EXCEL.EXE process
behind and the next time I try and run excel from Access it gets caught
in that loop recognising that theres an excel app running but unable to
close it
Any ideas why this happens or how I get rid of the rogue process?
Thanks in advance
Simon