Error when accessing workbook in PPT file RRS feed

  • Question

  • Hi,

    I am actually developing a PowerPoint addin that is using PowerPoint and Excel API to generate charts.

    Unfortunately it seems that sometimes, I am getting this exception "Error HRESULT E_FAIL has been returned from a call to a COM component." when accessing the chart workbook. It seems that this error appears without any reasons.

    Here is the faulty code:

    chartData = chart.ChartData as ChartData;
    workbook = chartData.Workbook as Microsoft.Office.Interop.Excel.Workbook;

    Also, it seems that the chart is corrupted because I am not even able to edit this chart in PowerPoint itself. However, i have no error message. Only accessing to the API from the workbook give me this error.

    Do you have any ideas ?

    Thanks a lot

    Monday, July 10, 2017 8:59 AM

All replies

  • Hi Vannick05,

    ->Unfortunately it seems that sometimes

    Do you mean the error does not always occurs? For the same chart, will you get error all times or some times?

    -> it seems that the chart is corrupted because I am not even able to edit this chart in PowerPoint itself

    Which version of Office and Visual Studio are you using? Does the error only occur on these chart which could not be edit? Is there any other code may cause this issue in your project? I suggest your create a new project to test accessing a chart workbook.

    Best Regards,


    Tuesday, July 11, 2017 7:20 AM
  • Hi Vannick05,

    Could you share us a simple demo which could reproduce your issue?

    I made a test with below code, it works correctly.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Office.Tools.Ribbon;
    using Microsoft.Office.Interop.PowerPoint;
    using Excel = Microsoft.Office.Interop.Excel;
    namespace PowerPointVSTOAddIn
        public partial class Ribbon1
            private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
            private void CreateChart_Click(object sender, RibbonControlEventArgs e)
                Chart chart = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes.AddChart2().Chart;
                Excel.Workbook workbook = (Excel.Workbook)chart.ChartData.Workbook;
                workbook.Windows.Application.Visible = true;

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, July 19, 2017 8:13 AM