ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Predicting that Excel is closing using events (https://www.excelbanter.com/excel-programming/277593-predicting-excel-closing-using-events.html)

Todd Webb

Predicting that Excel is closing using events
 
I am trying to monitor Excel behavior through events. To
do this I register with Application. If the end-user
manually closes Excel and my registration is still
active, the Excel process stays around in an un-dead
state until my process exits.

Suppose that I have Excel open with no open workbooks. If
the user closes Excel, I don't get any events. How do I
figure this out in time to remove my registration before
Excel tries to exit and hangs?

Rob Bovey

Predicting that Excel is closing using events
 
Hi Todd,

Unfortunately, there is no good answer to this. Excel doesn't expose any
events that would notify a controlling application that it's shutting down.
The best you can do is stash its window handle and always verify that you
can find an instance of Excel with that window handle before attempting to
do anything with your references. If you can't then set them all to nothing
and hope that takes care of it.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Todd Webb" wrote in message
...
I am trying to monitor Excel behavior through events. To
do this I register with Application. If the end-user
manually closes Excel and my registration is still
active, the Excel process stays around in an un-dead
state until my process exits.

Suppose that I have Excel open with no open workbooks. If
the user closes Excel, I don't get any events. How do I
figure this out in time to remove my registration before
Excel tries to exit and hangs?





All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com