none
Powerpoint displays a “can't start the application” error when an Excel Sheet object is embedded in it RRS feed

  • Question

  • My application acts as an addin to the Microsoft Excel and it is application level addin. This is a VSTO 2010 addin. I get this error when I try to inset Object to the powerpoint template.

    The startup,shutdown, InitEvents and DeinitEvents() are as follows. Am I missing out something? How can I overcome this?

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            XmlConfigurator.Configure();
            Vis_Ribbon ribbon = (Vis_Ribbon)ribbonObj;
            xclsComp = new ExcelComponent(Globals.ThisAddIn.Application);
            ribbon.XLCOMPONENT = xclsComp;
            InitEvents();
            ribbon.InitForms();            
            SingleSignOnStartup();
            InvalidateRibbon();
        } 
    
    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            SingleSignOnShutDown();
            DeinitEvents();    
            GC.Collect();
        }
    
    private void InitEvents()
        {
            this.Application.SheetSelectionChange += new Microsoft.Office.Interop.Excel.AppEvents_SheetSelectionChangeEventHandler(xclsComp.SelectionChangedEvent);
            this.Application.WorkbookDeactivate += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookDeactivateEventHandler(xclsComp.WBDeactivateEvent);
            this.Application.WorkbookOpen += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookOpenEventHandler(xclsComp.WBOpenEvent);
            this.Application.SheetActivate += new Microsoft.Office.Interop.Excel.AppEvents_SheetActivateEventHandler(xclsComp.SActivateEvent);
            this.Application.SheetDeactivate += new Microsoft.Office.Interop.Excel.AppEvents_SheetDeactivateEventHandler(xclsComp.SDeactivateEvent);
            this.Application.WorkbookActivate += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookActivateEventHandler(xclsComp.WBActivateEvent);
    
        }
    
    
    private void DeinitEvents()
        {
            this.Application.SheetSelectionChange -= new Microsoft.Office.Interop.Excel.AppEvents_SheetSelectionChangeEventHandler(xclsComp.SelectionChangedEvent);
            this.Application.WorkbookDeactivate -= new Microsoft.Office.Interop.Excel.AppEvents_WorkbookDeactivateEventHandler(xclsComp.WBDeactivateEvent);
            this.Application.WorkbookOpen -= new Microsoft.Office.Interop.Excel.AppEvents_WorkbookOpenEventHandler(xclsComp.WBOpenEvent);
            this.Application.SheetActivate -= new Microsoft.Office.Interop.Excel.AppEvents_SheetActivateEventHandler(xclsComp.SActivateEvent);
            this.Application.SheetDeactivate -= new Microsoft.Office.Interop.Excel.AppEvents_SheetDeactivateEventHandler(xclsComp.SDeactivateEvent);
            this.Application.WorkbookActivate -= new Microsoft.Office.Interop.Excel.AppEvents_WorkbookActivateEventHandler(xclsComp.WBActivateEvent);            
        }


    Roopini

    Wednesday, August 13, 2014 6:10 AM

All replies

  • Hello Roopini,

    What line of code exactly throws the exception? Did you try to debug the code?

    Wednesday, August 13, 2014 8:16 AM
  • public int CheckCellAndSetMenuState(Excel.Range target)
            {
                //Stopwatch timer = new Stopwatch();
                // Zum leeren der Werte
                mmdlModel.MultiSelect = new string[1];
                mmdlModel.MultiSelectMod = new string[1];
                bool l_mergedCells = false;

                if (target.MergeCells.GetType() == typeof(bool)) // this line is hitting the error
                {
                    l_mergedCells = (bool)target.MergeCells;
                }

    }

    Roopini


    • Edited by Roopini Wednesday, August 13, 2014 8:32 AM
    Wednesday, August 13, 2014 8:32 AM
  • My addin , as soon as the excel starts, it checks for this method. Should I deactivate this event?

    Roopini


    • Edited by Roopini Wednesday, August 13, 2014 8:44 AM
    Wednesday, August 13, 2014 8:34 AM
  • What property or method call exactly generates the exception?

    The following line of code contains multiple property and method calls:

    if (target.MergeCells.GetType() == typeof(bool)) 

    Which one exactly causes the issue? What range do you pass to the method?

    Wednesday, August 13, 2014 8:57 AM
  • WBOpenBookEvent()  has the   CheckCellAndSetMenuState(exlApplication.ActiveCell); method that is called on startup and for the 3rd call I am getting this error :( It says "Object reference not set to an instance of an object."

    Roopini


    • Edited by Roopini Wednesday, August 13, 2014 12:10 PM
    Wednesday, August 13, 2014 12:08 PM