none
C# Excel Interoop open workbook with Addin RRS feed

  • Question

  • Hi,

    I have installed addin in Excel. When i trying to open excel via c# my add in isnt open.

    try
                {
                    if (System.IO.File.Exists(this.ExcelPath) == true)
                    {
                        excel = new Excel.Application();
                        
                        workbook = excel.Workbooks.Open(this.ExcelPath, true, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
                        worksheet = workbook.ActiveSheet;
                        worksheet.Unprotect("PASS");
    
                        foreach (Excel.AddIn adin in excel.AddIns)
                        {
                            Console.WriteLine(adin.FullName + " " + adin.Installed + " " + adin.IsOpen.ToString());
                            
                         /* Here is my addin which is installed but not open*/
                        }
                        excel.Visible = false;
                        return;
                    }
                    throw new Exception("Excel does not exist!");
                }
                catch (Exception ex)
                {
                    workbook = null;
                    throw ex;
                }
    How open excel with ADDIN?

    Friday, October 11, 2019 6:57 AM

All replies

  • Hello,

    Do you see the add-in enabled in the COM add-ins dialog when you launch Excel manually

    Microsoft Office applications can disable VSTO Add-ins that behave unexpectedly. If an application does not load your VSTO Add-in, the application might have hard disabled or soft disabled your VSTO Add-in.

    Hard disabling can occur when a VSTO Add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your VSTO Add-in is executing.

    Soft disabling can occur when a VSTO Add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable a VSTO Add-in if it throws an unhandled exception while the Startup event handler is executing.

    When you re-enable a soft-disabled VSTO Add-in, the application immediately attempts to load the VSTO Add-in. If the problem that initially caused the application to soft disable the VSTO Add-in has not been fixed, the application will soft disable the VSTO Add-in again. Read more about that in the How to: Re-enable a VSTO Add-in that has been disabled article.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Friday, October 11, 2019 7:43 AM
  • Hi,
    Thank you for your interest and answer.

    When manually opening Excel, my "wom.xla" add-in is launched automatically. However, through the application written in C # the add-in does not open.

    Wednesday, October 16, 2019 6:34 AM