title: Powerpoint displays a "can't start the application" error when an Excel Chart object is embedded in it
body: <p>This is a very common problem when Excel Worksheet or Chart is embedded into Word or Powerpoint. I am seeing this problem in both Word and Powerpoint and the reason it seems is the COM addin attached to Excel. The COM addin is written in C# (.NET). See the attached images for error dialogs.</p>
  
  <p>I debugged the addin and found a very strange behavior. The OnConnection(...), OnDisConnection(...) etc methods in the COM addin works fine until I add an event handler to the code. i.e. handle the Worksheet_SheetChange, SelectionChange or any similar event available in Excel. As soon as I add even a single event handler (though my code has several), Word and Powerpoint start complaining and do not Activate the embedded object.</p>
  
  <p>On some of the posts on the internet, people have been asked to remove the anti-virus addins for office (none in my case) so this makes me believe that the problem is somewhat related to COM addins which are loaded when the host app activates the object.</p>
  
  <p>Does anyone have any idea of whats happening here?<a href="https://i.stack.imgur.com/kqkBv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kqkBv.png" alt="PowerPoint Error"></a>
  </p>
  
  <p><a href="https://i.stack.imgur.com/1yZMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1yZMK.png" alt="Word Error"></a>
  </p>
  
  <p><b>UPDATED 21-JUNE-2010</b>
  <hr>
  Found out that both Events and changes to ComAddIns collection creates problems when the embedded object is activated. I have now used the Excel::Application::UserControl property to check whether Excel is in embedded state and then skip any OnConnection(...) and OnDisconnection(...) code.</p>
  
  <p>One solution to Events problem can be to move all the application level events to VBA code and call into .NET. Thereby removing all event handlers from .NET code.</p>
  
  <p>There may be even more scenarios where an embedded object might fail to initialize so I choose to disable the COM addin i.e. skip the code in OnConnection(...) and OnDisconnection(...) methods altogether.</p>