Branislav B.
Branislav B.

Reputation: 557

VSTO Starting EXCEL in code ADDIN NOT LOADED

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.

Upvotes: 1

Views: 566

Answers (1)

Brijesh Mishra
Brijesh Mishra

Reputation: 2748

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;
         }
}

Upvotes: 1

Related Questions