5

I want to initialize a couple of variables on Excel Dna .dll gets loaded in the Excel?

jruizaranguren
  • 12,679
  • 7
  • 55
  • 73
Ocean
  • 293
  • 3
  • 14

1 Answers1

8

Excel-DNA will check whether your add has a public class that implements the interface ExcelDna.Integration.IExcelAddIn, and if so will run the AutoOpen method when the add-in is loaded, and the AutoClose method if the user removes the add-in from the add-ins list.

So you'd have something like:

public class MyAddIn : IExcelAddIn
{
    public void AutoOpen()
    {
        // Do your initialization here...
    }

    public void AutoClose()
    {
    }
}
Govert
  • 16,387
  • 4
  • 60
  • 70
  • Govert; Thanks for Update. This is certainly helpful. As I more look into ExcelDNA i am more enthused about that. I am planning to develop full fledge Add In which will have excel functions (i.e. UDF), custom task pane and custom ribbon. I will do all my coding in C# .dll; I do not want to rely on .dna file; i will just ExternalLibrary Tag in .dna file. Can I put all of these features in one .dll ? As of now I have I have ExcelFunction (i.e. UDF) within static class which is working fine. Thanks for your help in advance... – Ocean Jun 28 '12 at 13:38
  • You can do all of that in a single C# .dll, then pack everything into a single .xll file to give to your users. – Govert Jun 28 '12 at 15:25