none
_Application.AddIns collection always empty RRS feed

  • Question

  • Hello everyone!

    I'm trying to enumerate installed Word add-ins from external .NET application, but the _Application.AddIns collection always contains 0 elements(it is empty). I definitely have a bunch of add-ins installed for MS Word both COM and document-level. It can be seen from the Word Add-in manager as well as from the registry (for COM add-ins).

    Here's the code I use to do the trick:

     

    static void Main(string[] args)
    {
      Microsoft.Office.Interop.Word.Application WordApp = null;
      try 
      {
        WordApp = new Microsoft.Office.Interop.Word.Application();
        //Do we really need this ?
        /*WordApp.Visible = true;
        WordApp.Activate();*/
        int count = WordApp.AddIns.Count;
        System.Console.WriteLine("Count of installed Word add-ins is ", count);
      } 
      catch (COMException ex) 
      {
        System.Console.WriteLine("Failed to obtain list of installed add-ins");
      }
      finally
      {
        if (WordApp != null)
        {
          object saveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
          object format = Microsoft.Office.Interop.Word.WdOriginalFormat.wdWordDocument;
          object routeDocument = null;
          WordApp.Quit(ref saveChanges, ref format, ref routeDocument);
        }
      }
    } 
    

     

     

    I'd very much appreciate any ideas on why this is happening. Thanks a lot!



    Thursday, March 31, 2011 2:47 PM

All replies

  • Hi Gennadi

    The Addins collection in Word refers to template-level add-ins (templates in Word's Startup folder, for example).

    If you want to check COM Add-ins, use the ComAddins collection, instead.

    Note, however, that this collection only "sees" Add-ins registered in the HKCU (same as the UI). Anything registered in the HKLM is not "visible" to Word.


    Cindy Meister, VSTO/Word MVP
    Thursday, April 7, 2011 2:07 PM
    Moderator