When switching between workbooks, if the users clicks the 'X' directly on the Excel workbook window bar

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

When switching between workbooks, if the users clicks the 'X' directly on the Excel workbook window bar
 
MarcumLLP




Posts: 31
Joined: 2015-02-10
When switching between workbooks, if the users clicks the 'X' directly on the Excel workbook titlebar, HostApplication.ActiveWorkbook still references the non focused workbook. This is only true if the user does not click on a cell first, then clicks 'X' to close the window.

The event for workbookBeforeClose() doesnt have the correct HostApplication.ActiveWorkbook, for the workbook that is being closed.

How can I get the Workbook that is being closed in this case?

Thank you
Posted 20 Apr, 2017 10:51:41 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello,

MarcumLLP writes:
When switching between workbooks, if the users clicks the 'X' directly on the Excel workbook titlebar, HostApplication.ActiveWorkbook still references the non focused workbook. This is only true if the user does not click on a cell first, then clicks 'X' to close the window.


This issue belongs to the Excel object model.
MarcumLLP writes:
The event for workbookBeforeClose() doesnt have the correct HostApplication.ActiveWorkbook, for the workbook that is being closed


Cast e.HostObject to Excel.Workbook - this is the workbook being closed.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Apr, 2017 11:02:42 Top
MarcumLLP




Posts: 31
Joined: 2015-02-10
Great thank you
Posted 20 Apr, 2017 13:19:05 Top