Thanks for responses to date:
techgnome:
As you aptly point out it appears when user is closing Excel directly, the ActiveWorkbook is closed (by Excel I assume) and consequently the reference (in VB) is no longer valid (left hanging).if the user "closes" Excel, there is no longer an ActiveWorkbook.
Excel is still running in the background (I assume because of COM), hence the oxlApp VB object reference is still active.
Using "On Error Resume Next" allows the code to bypass the ActiveWorkbook reference and excecute oxlApp.Quit, which shuts down Excel from the VB App
and does not generate the Error (call to my routine).
Other than "ON ERROR Resume Next" any other work around ?
///////////// UPDATE //////////////////////
Modifying Bonnie West's post (Thanks Bonnie), the following code worked
Code:If Not oxlApp.ActiveWorkbook Is Nothing Then oxlApp.ActiveWorkbook.Close False




Reply With Quote