SOLVED

Add-in registry access problem

Copper Contributor

I am the author of an add-in (Rainbow Analyst) which retrieves certain stored user details from the Windows Registry during startup. This code has operated without any problem for some years now, but following the latest (November 2018) update to Windows 10 1803 and/or Office 365 (64-bit version), when I click an existing (i.e. Recent) Excel workbook in the Excel startup screen, Excel silently crashes (closes) before displaying the add-in.

 

I have traced the crash to the code which accesses the Registry, because although the crash occurs some time after this code is executed, it seems (from experiment) that it can only be prevented by eliminating this section of code (not feasible in practice, as essential user details are stored in the Registry).

 

There is no problem if I click "Blank workbook" and then subsequently open an existing workbook, and I have also ascertained that the crash only occurs when the Registry is accessed more than once; it can be avoided if I modify the code to limit it to a single Registry access (not feasible in practice). I currently use the VBA GetSetting function, but the same problem occurs if I create a WScript.Shell object and use the RegRead method.

 

I am new here, so I hope this is the correct place to raise this problem. Any suggestions will be much appreciated!

4 Replies
best response confirmed by mike_s (Copper Contributor)
Solution
Does it help to postpone the registry reads until Excxel has really fininshed starting up? What I usually do to allow Excel to finish it's business during startup is (in Workbook_Open) schedule a macro called "ContinueOpen" situated in a normal module using Application.Ontime. This prevents all sorts of issues stemming from Excel not having finished to load completely when your Workbook_Open is called.
Many thanks Jan Karel for this prompt and helpful response; much appreciated, and I'll certainly give this a go. There's a slight potential issue because the add-in uses the registry reads to determine what tab or icon to display on the Ribbon (using the isVisible property of the IRibbonControl objects), but I guess it shouldn't be a problem to delay the Ribbon display by a fraction of a second. I'll try it and post again to confirm the outcome.
Excellent; this has solved the problem! I've set all custom tabs as initially invisible, then run the rest of the start-up code after one second and refreshed the ribbon (with .Invalidate), and all works fine. Many thanks again for your help.
You're welcome. I have fixed issues like these using this technique in quite some of my add-ins as available through https://jkp-ads.com/download.asp
1 best response

Accepted Solutions
best response confirmed by mike_s (Copper Contributor)
Solution
Does it help to postpone the registry reads until Excxel has really fininshed starting up? What I usually do to allow Excel to finish it's business during startup is (in Workbook_Open) schedule a macro called "ContinueOpen" situated in a normal module using Application.Ontime. This prevents all sorts of issues stemming from Excel not having finished to load completely when your Workbook_Open is called.

View solution in original post