After Closing events missing for Word and Excel

Add-in Express™ Support Service
That's what is more important than anything else

After Closing events missing for Word and Excel
There are no After Close events in Add-in Express for Word or Excel 
Tim Overton




Posts: 23
Joined: 2015-11-15
Hi Guys,

We need to trigger an action after a Document or Workbook is closed (regardless of whether its saved or not).

We have worked out a way we can do this for Word, using the Document Change event, as per previous Forum posts.

For Excel, we have worked out a solution using Workbook activate and deactivate. However the solution for Excel is not working consistently, eg. switching between workbooks causes these events to fire. We need an event when the Excel Workbook closes, independent of whether the workbook was saved or not.

We urgently need a fix or workaround. Looking forward to hearing from you,
Tim
Posted 01 Nov, 2018 02:05:52 Top
Andrei Smolin


Add-in Express team


Posts: 17113
Joined: 2006-05-11
Hello Tim,

We are unable to fix anything in an Office object model. This can only be done by Microsoft.

If you save the workbook, you get the WorkbookAfterSave even; not sure if it is of help.

If the workbook is closed without saving, I suppose another workbook (and window) gets activated. If the workbook gets closed as part of closing Excel, your only way is to study the events that occur during this process. Pay attention to the CommandBarsUpdate event that the ADXExcelAppEvents component provides. That event originates from the CommandBars.OnUpdate event which is a heartbeat event. In the code of that event you could check whether the workbook opened during the previous run is now closed. Your code should be effective to prevent Excel performance degradation.

In the sample add-in described in Excel shapes events: getting notified about user actions, I use that event to analyze the selection and generate events missing in the Excel object model.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 01 Nov, 2018 02:24:12 Top
Tim Overton




Posts: 23
Joined: 2015-11-15
Thanks for the quick reply Andrei, we will give this solution a try in the morning.

Kind Regards,
Tim
Posted 01 Nov, 2018 06:58:27 Top
Andrei Smolin


Add-in Express team


Posts: 17113
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 01 Nov, 2018 07:14:05 Top