none
Deleting the UsedRange for a PowerPoint chart's ChartData causes an exception when writing new data RRS feed

  • Question

  • Hi all;

    This is happening in PowerPoint. But because it's an error with a chart (Excel code) and the specific error in on accessing an Excel Range, I'm asking here.

    When I go to update the data in a PowerPoint chart from my AddIn (COM API) I start with:

    ChartData chartData = shapeChart.Chart.ChartData;
    chartData.Activate();
    WorksheetData = (Worksheet) WorkbookData.Worksheets[1];
    WorksheetData.UsedRange.Delete();
    

    If I call UsedRange.Delete(), then when I go to write data to the worksheet I get a COMException 0x800AC472. No error if I don't make that call.

    I write to the worksheet with the code:

    ((Range)WorksheetData.Cells[indexRowSeriesStart + index + 2, 1]).Value2 = "test";
    

    Do I need to set the size of the worksheet for the chart somehow? Or because it's in use (I'm updating an existing chart) do I need to disconnect it or something?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing


    • Edited by DavidThi808 Monday, December 10, 2018 5:27 PM
    Monday, December 10, 2018 5:26 PM

Answers

  • Hi dave,

    >> If I call UsedRange.Delete(), then when I go to write data to the worksheet I get a COMException 0x800AC472. No error if I don't make that call.

    This exception, 0x800AC472 – VBA_E_IGNORE, is thrown because Excel is busy and will not service any Object Model calls.

    Here is one of the discussions that talks about this:

    HRESULT 800ac472 from set operations in Excel

    The work around is to explicitly catch this exception and retry after sometime until your intended action is completed.

    For more information, please review the following link:

    writing data from C# to Excel interrupted by opening Excel Window

    Hopefully it helps you.

    Best Regards,

    Yuki


    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.

    • Marked as answer by DavidThi808 Tuesday, December 11, 2018 12:36 PM
    Tuesday, December 11, 2018 6:42 AM
    Moderator

All replies

  • Hi dave,

    >> If I call UsedRange.Delete(), then when I go to write data to the worksheet I get a COMException 0x800AC472. No error if I don't make that call.

    This exception, 0x800AC472 – VBA_E_IGNORE, is thrown because Excel is busy and will not service any Object Model calls.

    Here is one of the discussions that talks about this:

    HRESULT 800ac472 from set operations in Excel

    The work around is to explicitly catch this exception and retry after sometime until your intended action is completed.

    For more information, please review the following link:

    writing data from C# to Excel interrupted by opening Excel Window

    Hopefully it helps you.

    Best Regards,

    Yuki


    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.

    • Marked as answer by DavidThi808 Tuesday, December 11, 2018 12:36 PM
    Tuesday, December 11, 2018 6:42 AM
    Moderator
  • Hi;

    Ok, now I know what I have to work with. Waiting and retrying won't work because we've then locked the user up. 

    You're telling me that we basically can't do this helped - it made me look for an alternative. And this works:

    WorksheetData.UsedRange.Clear();

    That gives me what I need and no error returned.

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Tuesday, December 11, 2018 12:36 PM