Forcing RegisterXLL function to return false

94 views
Skip to first unread message

Andrew Lockhart

unread,
May 1, 2019, 8:43:11 AM5/1/19
to Excel-DNA
Hi,

I've created an XLL/COM addin project like the example in the distribution, ComAddInRegisterObject.dna, but using C#. I'm writing some error handling at start up and there are certain situations where the XLL/COM addin will not be able to load and run the code, but not initialise correctly, such as missing environment variables etc. - run-time errors in the COM Addin OnConnection Method. I have a VBA Addin that is calling RegisterXLL to start up my XLL/COM object.

RegisterXLL returns a Boolean; is there a way to programmatically set this return value? Auto_Open doesn't return a value and throwing an exception from Auto_Open causes the ExcelDNA diagnostics to come up. Ideally I would like my VBA code to try and load the add-in and be able to detect if there are any initialisation errors.

Or is the recommendation to hold a global in the C# that I query from a very simple XLL function called something like InitialisedOK?

Regards

Govert van Drimmelen

unread,
May 1, 2019, 4:56:30 PM5/1/19
to exce...@googlegroups.com

Hi Andrew,

 

Microsoft’s documentation for xlAutoOpen (the .xll entry point) states that:

“Your implementation of this function must return 1 (int).”

So it does not seem like an appropriate mechanism for indicating some error during loading.

There might be some other error cases that cause RegisterXLL to return something interesting, of course.

 

In Excel-DNA the plumbing around AutoOpen is not likely to change anyway, so I can’t see a good way to thread some result code back with this mechanism.

 

Your add-in specific mechanism with a simple XLL function (which you can make hidden so it doesn’t show up the functions dropdown) should be fine. It can even return a string with some diagnostic information if there is an error.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Andrew Lockhart

unread,
May 29, 2019, 6:12:20 PM5/29/19
to Excel-DNA
Thanks, that's exactly what I did and it worked fine.
Regards

To unsubscribe from this group and stop receiving emails from it, send an email to exce...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages