Search code examples
c#excelembedadd-inribbon

Create an Excel Add In Application in C#


I'd like to create an Excel Add In. But I want it to have a special behavior.

Then problem is that the Excel Add In I developed stays within Excel. Even when I run a normal Excel instance from Windows...

So what I want, to be more precise, is to have an Excel add in that will only appear in the Excel's ribbon when launched by my own C#_made application.

How should I do that ?

The behavior would be :

  • Run my C# application
  • My C# application calls a new Excel's instance
  • My C# application adds a new tab (and its elements) to the ribbon of this Excel's instance
  • My C# application adds actions binded to the tab's elements
  • Excel's instance is being closed > Remove all added components, functions, methods, ...
  • Close my C# appliclation

Solution

  • Here's a nice tutorial for you: http://www.add-in-express.com/free-addins/net-excel-addin.php

    Edit:

    Have you considered just disabling the addin, then reenabling it whenever you launch the app with a server that runs in the background and when excel is closed, disables the addin?

    Here's some unload code I found here:

    private void UnloadBadAddins(bool unloadAddin)
    {
        const string badAddin = "iManage Excel2000 integration (Ver 1.3)";
    
        foreach(Office.COMAddIn addin in this.ExcelApp.COMAddIns)
        {
            if (addin.Description.ToUpper().Contains(badAddin.ToUpper()))
            {
                if (addin.Connect == unloadAddin)
                {
                    addin.Connect = !unloadAddin;
                    return;
                }
            }
        }
    }