Home » excel » c# – Excel-DNA: Unregister methods in a running instance of Excel

c# – Excel-DNA: Unregister methods in a running instance of Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

Is it possible to unregister methods that I previously registered via ExcelIntegration.RegisterMethods without restarting Excel?

Basically, I’m looking for the opposite of ExcelIntegration.RegisterMethods.

How to&Answers:

Excel-DNA does not currently let you unregister methods in a loaded add-in. This is just a limitation of the implementation, and how exported functions are hooked up to the native exports of the .xll. You an however unload an entire Excel-DNA add-in, (from another add-in) as long as it only exports UDFs and not ribbons, an RTD server or other COM features.

Another workaround is to re-register the function as “hidden”. The new registration will take up another slot in the (fixed-size) .xll export table, but will at least not appear in the worksheet function completion list anymore.