View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Hanging Instances Of EXCEL.EXE?

Hey all,

I'm working with Excel from within Access using automation. I'm running a comparison between two tables, and checking for differences. The results will be displayed in an Excel sheet.

I know that when you're working with Excel, you should kill all instances of it (objXL.Quit, etc.) However, if certain criteria are met, I want to display the newly-created workbook on the screen....users could use the "Save As" option and do with it what they like - I have no interest in it after that. If I do that, would I still need to kill Excel, or would their closing the program handle that? Here's a skeleton of the code. objXL and objWB have module-level scope.

' Assume no differences
blnDifferences = False

' Create a handle to Excel
Set objXL = CreateObject("Excel.Application")

' We'll start a workbook with 0 sheets - we'll add sheets as needed
objXL.SheetsInNewWorkbook = 0
Set objWB = objXL.Workbooks.Add
objXL.SheetsInNewWorkbook = 3

' SUBS GO HERE - TO RUN CHECKS

If blnDifferences Then

objXL.Visible = True
' ?? Anything else here?

Else

MsgBox "No differences have been found.", vbInformation, "Check OK"

objWB.Close
Set objWB = Nothing

objXL.Quit
Set objXL = Nothing

End If