Message 1 of 9
How to end Excel from VBA

Not applicable
04-29-2003
12:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having a hell of time trying to close down excel from my vba program.
My operating system is Windows 98.
Here is the code:
Private Sub Excel_Running_Check()
Dim excelApp As Excel.Application
On Error Resume Next
Err.Clear
Set excelApp = GetObject(, "excel.application")
If Err <> 0 Then
Err.Clear
Else
excelApp.DisplayAlerts = False
excelApp.ActiveWorkbook.Close
excelApp.Quit
Set excelApp = Nothing
End Sub
The idea for this sub is to check for a running instance of excel. If it
exists then close it down before opening up another instance of excel. The
problem is that excel still remains memory resident. I verify this by using
ctrl-alt-del to open the task manager and notice that excel is still
running. The only way I can get excel to stop running is to close down my
application with the End function. I've seen similar posts all over the
internet but I haven't found an answer to it yet. The fact that excel is
not released from memory causes problems when reopening excel through my
program. Subsequent intances of spreadsheets are not formatted
programatically as is intended through my code. Several instances of excel
remain running in task manager. Please help.
My operating system is Windows 98.
Here is the code:
Private Sub Excel_Running_Check()
Dim excelApp As Excel.Application
On Error Resume Next
Err.Clear
Set excelApp = GetObject(, "excel.application")
If Err <> 0 Then
Err.Clear
Else
excelApp.DisplayAlerts = False
excelApp.ActiveWorkbook.Close
excelApp.Quit
Set excelApp = Nothing
End Sub
The idea for this sub is to check for a running instance of excel. If it
exists then close it down before opening up another instance of excel. The
problem is that excel still remains memory resident. I verify this by using
ctrl-alt-del to open the task manager and notice that excel is still
running. The only way I can get excel to stop running is to close down my
application with the End function. I've seen similar posts all over the
internet but I haven't found an answer to it yet. The fact that excel is
not released from memory causes problems when reopening excel through my
program. Subsequent intances of spreadsheets are not formatted
programatically as is intended through my code. Several instances of excel
remain running in task manager. Please help.