Excel 2016 creates second Workbook instance on startup RRS feed

  • Question

  • I have an application level Excel add-in in which I want to create some custom cell styles so that all styles are available across versions 2010, 2013 and 2016.

    To do this the following method is called from ThisAddIn.cs.

            private static void CellLightRed()
                // create new style
                Excel.Office.Interop.Workbook wb = Globals.ThisAddIn.Application.Workbooks.Add();
                Excel.Style style = wb.Styles.Add("20% - Accent7");
                // color
                int index = ColorsList._colorsList.Find("Name", "2010 - 20% - Accent2");
                style.Interior.Color = ColorsList._colorsList[index].RGB;

    This works fine in Excel 2010 and 2013.  However in Excel 2016 I get a second instance of a Workbook when starting Excel.

    Is there any way to avoid this second instance?

    Thanks for your help.

    Regards Don

    Tuesday, February 18, 2020 6:12 AM


  • Rather than add the styles on startup I decided to check for and then add them when first required.  That way I can add them to the ActiveWorkbook, thus avoiding the problem.
    • Marked as answer by donvreug Friday, June 26, 2020 10:52 PM
    Tuesday, February 18, 2020 8:20 PM