Home » excel » c# – Call Excel VB AddIn From Macro

c# – Call Excel VB AddIn From Macro

Posted by: admin April 23, 2020 Leave a comment

Questions:

So I’m trying to build a series of data entry forms in Excel that are coded in C# in visual studio. I’d like to be able to store an entire library of these forms in an add-in, and only show certain forms depending on the excel document that’s open. I know that with a few tricks, the excel ribbon can be customized per individual document,

(ex.)
http://www.rondebruin.nl/win/s2/win001.htm

but I’ve only been able to find ways to run macros from the customized ribbon… Is there a way to reference a C# Add-In from a macro? If not, is there a way to reference it from building a custom xml Add-In?

How to&Answers:

You need to expose the classes and objects of the add-in to be able to use them outside of the add-in in VBA.

Here’s a nice tutorial on how to do this: http://msdn.microsoft.com/en-us/library/bb608614.aspx