My Excel
addin (XLL AddIn, call it MyAddIn
) is built with C#, ExcelDNA, NetOffice, VS2010. Client has another addin (let's call it B
), I guess it is written in VBA.
Client says B
works fine without MyAddIn
. Once MyAddIn
is installed, B
fails with error:
Error code: 406 Error message: Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page.
I did see this Microsoft resource, but I do not want to just tell the client that B
addin needs changing. I want to do something to avoid this from my side.
Here is the steps reported to see the issue:
Excel
. MyAddin
is installed, it makes a registry entry for Microsoft Excel
. Excel
is launched, so B
addin is not launched, Excel
works fine, MyAddIn
works fine. B
addin is launched, it gives the 406 error shown above.B
addin; disabling MyAddIn
is the workaround. B
addin is launched, we see that MyAddIn
is loaded first before the B
addin and then get the 406 error. MyAddIn
, this error is no longer encountered and everything works fine.B
addin always open before MyAddin
.
Excel
, which means B
addin will always open, even when we launch only Excel
. This is not desired, as B
addin then can't let users work with the static data as the B
addin keeps on refreshing real-time. That is the reason the B
addin doesn't make an entry in the registry settings. So registry changes are not an option. We can’t always open B
addin whenever Excel
is open.I don't have an answer, but here are a couple of things you can try.
You can tell what type of Addin you are dealing with by executing File | Options and selecting the Addins Tab.
If the event happens as soon as you load Addin B
, it probably means you are calling a non-modal dialog box as it states, but there are a few other things that could give you similar errors.
Based on your description, it sounds like the error could either be a dialog box in your Addin, or it could be in the other addin, and it gets called as a side effect of some state change your addin made.
To get to the bottom of it, you need to attach a debugger. You can do that by making Excel your Startup Project, or by attaching later. The former is probably easier in this case.
In Visual Studio, Use Project | Properties | Debug, select Start external program and put in the fully qualified pathname to Excel.
Load Addin B
manually to give yourself the error
Break into the debugger and examine the call stack.
That will frequently but not always give you good clue as to where the problem is, but it's always the first step. If it doesn't give you useful information (stack info is frequently completely lost in transitions between addins), you may want to put some breakpoints in your projects in any events you handle. Even this doesn't reliably work all the time, but it's worth a shot.
If I had to guess, I would say probably have some event handlers in your add-in that are causing the problem, And you might have to do something like change a .Show
to a `.ShowDialog', or defer the processing of the form until outside the event handler but that's just a guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With