Search code examples
c#vstopowerpoint-2010

how to auto-unload a custom add-in in PowerPoint using C# VSTO?


I have created an add-in in PowerPoint 2010. I need to check the current version of the PowerPoint being used by the user and if the current version is less than 14.0, I need to show a message and also that the add-in is unloaded automatically(or the user is not able to install or select the add-in).

Is there an easy way to do this? I am using C#. Thanks.


Solution

  • See COMAddIns.Item and COMAddIn.Connect.

    COMAddIn addin = Application.COMAddIns.Item("yourAddinProgId");
    addin.Connect = false;
    

    This will cause the Shutdown event of your Add-In to be raised. But you'll have to do all the cleanup yourself (undo everything you did on startup).