Tim Overton
Guest
|
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 |
|
Andrei Smolin
Add-in Express team
Posts: 18817
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 https://www.add-in-express.com/creating-addins-blog/2012/02/21/excel-shapes-events/, I use that event to analyze the selection and generate events missing in the Excel object model.
Andrei Smolin
Add-in Express Team Leader |
|
Tim Overton
Guest
|
Thanks for the quick reply Andrei, we will give this solution a try in the morning.
Kind Regards,
Tim |
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
You are welcome!
Andrei Smolin
Add-in Express Team Leader |
|