MWE
09-11-2010, 08:56 AM
I am running MS Office 2003. I have dozens of VBA procedures that run in Access, Outlook, PowerPoint, Project and Word that open Excel workbooks for information. They all work essentially the same way, typical code is
Dim xlAppl As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim xlBookName As String
Dim xlSheetName As String
Set xlAppl = CreateObject("Excel.Application")
Set xlBook = xlAppl.Workbooks.Open _
(xlBookName, UpdateLinks = False)
Set xlsheet = xlBook.Worksheets(xlSheetName)
' do operations
xlCleanUp:
xlBook.Close SaveChanges:=False
xlAppl.Quit
Set xlsheet = Nothing
Set xlBook = Nothing
Set xlAppl = Nothing
All these procedures work fine. But when I do the same type of thing from inside Outlook, I often encounter a problem. The codes runs fine and do exactly what I want. But the Excel instance does not always disappear (as it does with other appls) until I close Outlook. If I run 3 such procedures during an Outlook session, there are normally 3 instances of Excel shown in the Processes window of Task Master. All disappear when I close Outlook.
Any idea what is happening here? Any thoughts on how I can force the Excel instance to actually Quit?
Thanks
Dim xlAppl As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim xlBookName As String
Dim xlSheetName As String
Set xlAppl = CreateObject("Excel.Application")
Set xlBook = xlAppl.Workbooks.Open _
(xlBookName, UpdateLinks = False)
Set xlsheet = xlBook.Worksheets(xlSheetName)
' do operations
xlCleanUp:
xlBook.Close SaveChanges:=False
xlAppl.Quit
Set xlsheet = Nothing
Set xlBook = Nothing
Set xlAppl = Nothing
All these procedures work fine. But when I do the same type of thing from inside Outlook, I often encounter a problem. The codes runs fine and do exactly what I want. But the Excel instance does not always disappear (as it does with other appls) until I close Outlook. If I run 3 such procedures during an Outlook session, there are normally 3 instances of Excel shown in the Processes window of Task Master. All disappear when I close Outlook.
Any idea what is happening here? Any thoughts on how I can force the Excel instance to actually Quit?
Thanks