I am making a VSTO PowerPoint add-in, that adds charts to a slide among other things. When I add a chart I use the following line of code:
private void button2_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes.AddChart(XlChartType.xlLine);
}
This works, and the chart gets added. However, if the user has an Excel application open and is actively editing a cell, I get the following Exception:
System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'
I found this blog post regarding this issue, but seeing as my add-in is made in PowerPoint, I don't have access to the Excel application. Is there any way in VSTO to make sure that Excel is not in edit mode from a PowerPoint add-in?