Perlimpinpin
Perlimpinpin

Reputation: 104

System.Runtime.InteropServices.COMException HRESULT : 0x800A03EC ObjectCharts Paste

I have this code

targetSheet = (Excel.Worksheet)excelWorkBook.ActiveSheet;
                        Excel.ChartObject myChart1 = targetSheet.ChartObjects("mco");       
                        myChart1.Copy();
                        Microsoft.Office.Interop.PowerPoint.ShapeRange shape2 = sld.Shapes.Paste();

                        Excel.Worksheet targetSheet2 = (Excel.Worksheet)excelWorkBook.ActiveSheet;
                        Excel.ChartObject myChart2 = targetSheet2.ChartObjects("txAnnul");
                        myChart2.Copy();
                        Microsoft.Office.Interop.PowerPoint.ShapeRange shape3 = sld.Shapes.Paste();

                        Excel.Worksheet targetSheet3 = (Excel.Worksheet)excelWorkBook.ActiveSheet;
                        Excel.ChartObject myChart3 = targetSheet3.ChartObjects("perceived");
                        myChart3.Copy();
                        Microsoft.Office.Interop.PowerPoint.ShapeRange shape4 = sld.Shapes.Paste();

When I take only the two first charts it works fine and i have my two charts in my pptx, but when I add the third one "myChart3" I'm getting the error I mentionned in this topic title. Any idea of how can I sovle this please? Thank You

Upvotes: 2

Views: 690

Answers (1)

Perlimpinpin
Perlimpinpin

Reputation: 104

I solved my problem, by using : myChart1.Chart.ChartArea.Copy(); istead of myChart1.Copy();. I don't know what really happens, but i will investigate to find what's the difference between a chart.copy() and chart.chartarea.copy(). Hope that this solution can help peoples which are facing the same problem.

Upvotes: 1

Related Questions