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:
Code:
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!