【问题标题】:System.Runtime.InteropServices.COMException HRESULT : 0x800A03EC ObjectCharts PasteSystem.Runtime.InteropServices.COMException HRESULT:0x800A03EC ObjectCharts 粘贴
【发布时间】:2017-06-14 07:35:22
【问题描述】:

我有这个代码

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();

当我只取前两个图表时,它工作正常,并且我的 pptx 中有两个图表,但是当我添加第三个“myChart3”时,我收到了我在这个主题标题中提到的错误。 请问我该如何解决这个问题?谢谢你

【问题讨论】:

  • 这个问题合适吗? stackoverflow.com/questions/29396451/…
  • 实际上,这是相同的错误消息,但在他的帖子中,他在使用导出图像时遇到了错误,我在尝试复制粘贴图表时遇到错误.. .他说我们使用xlsx文件时没有问题,我的文件有xlsx扩展名!

标签: c# excel-interop


【解决方案1】:

我解决了我的问题,通过使用: myChart1.Chart.ChartArea.Copy(); 而不是 myChart1.Copy();。我不知道到底发生了什么,但我会调查以找出 chart.copy() 和 chart.chartarea.copy() 之间的区别。 希望这个解决方案可以帮助面临同样问题的人们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-21
    • 2011-05-23
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多