1

I'm launching Excel from code using this code :

var excelApp = new MSExcel.Application { Visible = true };
excelApp.Workbooks.Add();
excelApp = null;

I've added the second line because without it the Excel automatically closes when the launcher closes. When I add new workbook it keeps alive. Howewer, my add-in that has nothing to do with the launcher won;t load. Any suggestions ?

Thanks for your advice.

Keith
  • 20,636
  • 11
  • 84
  • 125
Branislav B.
  • 509
  • 7
  • 21
  • Can you explain a bit what you are trying to do here? I assume this code is not in an add-in, what is running this code? – Mathias Apr 12 '12 at 05:10
  • Im running excel from console app using the code above. Excel never loads Any addins when it is initialized like this. – Branislav B. Apr 12 '12 at 12:25
  • 1
    A workaround: If you don't need your console app to interact with Excel, then start the Excel app using `Process.Start()`. This is the same as opening the app from the Start menu, thus all add-ins will load automatically. – Keith Apr 12 '12 at 19:53
  • is the addin getting disabled? can you load addin manually or do you have multiple version of excel installed? – Brijesh Mishra Apr 13 '12 at 12:20

1 Answers1

1

idealy mustnot happen, but a workaround you may try

foreach (COMAddIn addin in application.COMAddIns)
{
      if (addin.Description.ToLower().Equals(addinName.ToLower()) || string.Equals(addin.Description, "[AddInName]", StringComparison.OrdinalIgnoreCase))
       {
            addIn.Connect = true;
            break;
         }
}
Brijesh Mishra
  • 2,738
  • 1
  • 21
  • 36