VegDork
VegDork

Reputation: 266

Excel-DNA Getting a reference to a ribbon from static function class

I have an excel dna class library that contains a custom ribbon and a static class that contains my UDFs for the application.

How do I get a reference to the ribbon from the class containing the UDFs.

For information my ribbon contains a reference to some settings (entered in a form) that I also want available to the functions in my UDF class.

Upvotes: 1

Views: 363

Answers (2)

C. Augusto Proiete
C. Augusto Proiete

Reputation: 27898

Hmm... Having your UDFs tightly coupled with a Ribbon doesn't seem like a good design IMO. A UDF should not know anything about the existance of a Ribbon or Form...

I'd suggest you create a static class to store configuration settings that you can use in your UDFs, assign default values to these settings, so that your UDFs work out-of-the-box, and let the user override these settings through the form that you are opening through the Ribbon... i.e. When the user changes these settings, you simply update your static configuration class, and your UDFs won't have to have any knowledge of the Ribbon or Form...

Upvotes: 1

Govert
Govert

Reputation: 16907

I think you can store the ribbon instance in a static variable when it is created (i.e. in your ExcelRibbon-derived classes constructor).

Upvotes: 1

Related Questions