Question

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

Was it helpful?

Solution

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()
    {
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top