Excel WorkbookOpen Event

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

Excel WorkbookOpen Event
Does not fire when opening the workbook by double clicking in File explorer 
Fred Balkenende




Posts: 29
Joined: 2007-07-05
Hello,

On some machines (2 Windows 10 running Office 2016) the WorkbookOpen event does not fire when the workbook is opened by either double-clicking the file in File explorer, or opening it from the 'recent' list in the taskbar. When first opening Excel, it works fine. I also have knowledge of Win10 machines running 2016 which do not have this problem. I do not know if the problem exists when using other Windows/Office versions.

I have updated to the newest Addin-Express version, and that does not help.

Any idea where to start to solve this problem?

Thanks in advance!

Regards
Fred Balkenende
Posted 02 Oct, 2017 11:23:10 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Fred,

This is how Excel behaves. Your add-in should check if other workbooks are already opened at startup.


Andrei Smolin
Add-in Express Team Leader
Posted 03 Oct, 2017 01:27:12 Top
Fred Balkenende




Posts: 29
Joined: 2007-07-05
Hi Andrei

Thanks for the quick response! You are right, at startup the workbook is already open when I double-click the file in File explorer. But this is not the case on all machines? Can I be sure the WorkbookOpen event will not be fired when the workbook is already open at startup?

Regards
Fred
Posted 03 Oct, 2017 03:30:16 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Fred,

I believe the Excel object model doesn't raise the WorkbookOpen event for a workbook that is already open.


Andrei Smolin
Add-in Express Team Leader
Posted 03 Oct, 2017 03:53:34 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Fred,

I get one more report about this issue. In an email to the support email address, the customer states that the WorkbookOpen event missing is caused by the Excel build used; it is version 1708 - Build 8413.2079 in his case.

I reproduce the issue in my Excel 2016 version 1710 build 8613.1000 32bit ?Â?Ð?ã this is Office Insider Fast.

To test the issue I double-click a macro-enabled workbook. Debug messages show that the WorkbookOpen event occurs before the COM add-in gets loaded. This is why your add-in doesn't get this event. But in previous Excel builds the event was raised in this scenario! Say, I receive it in Excel 2010. This may look like an issue with Excel. But this isn't so because you won't receive the WorkbookOpen event for workbooks that are open if you turn your add-in on *after* Excel is started. To handle these two scenarios (getting the event and not getting it depending on the Excel version and actual scenario), you need to do the following:
- at the add-in startup, you process the workbooks that are open and create a list of workbooks processed;
- when the WorkbookOpened event is raised you process the workbook being opened *only* if it isn't already exist on the list;
- you update the list when a workbook gets closed.


Andrei Smolin
Add-in Express Team Leader
Posted 04 Oct, 2017 04:00:06 Top
Fred Balkenende




Posts: 29
Joined: 2007-07-05
Hi Andrei

Thanks for the information and solution!

Regards
Fred
Posted 05 Oct, 2017 03:24:34 Top
Andrei Smolin


Add-in Express team


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


Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2017 03:28:09 Top