none
Excel 2016 - Issue with adding and deleting shapes (Exception from HRESULT: 0x800AC472) RRS feed

  • Question

  • This problem i am facing when i try to remove some shape objects and place some new shapes.

    In our application we export charts to excel. There can be n number of charts on a excel-sheet.

    Our addin application exposes a button for refresh.

    It basically reads alternate text of all shapes (we keep some sort of object identifier there). Make chart requests. and as and when the response comes back - a new chart will get added and the corresponding old chart would get removed.

    This works fine in all office so far - 2007, 2010 & 2013.

    But with 2016 we are facing issues. Some times when it goes to read shape object it throws COM exception

    aShape = activeWorkSheet.Shapes.Item("Picture 10"); 


    Exception reads something like following:

    2015-09-24 12:51:43.318 [EROR] [4076|5 ] [ICExcelAddIn           ] [_addInChart_Downl]	System.Runtime.InteropServices.COMException (0x800AC472): Exception from HRESULT: 0x800AC472
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Shapes.Item(Object Index)
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn.ReplaceShapeInExcel(String strPath, String key, String strAlternativeText, String strGUID, String strErrorMessage)
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn._addInChart_DownloadComplete(Object sender, ICAddInEventArgs e)
    2015-09-24 12:51:43.360 [EROR] [4076|4 ] [ICExcelAddIn           ] [_addInChart_Downl]	System.Runtime.InteropServices.COMException (0x800AC472): Exception from HRESULT: 0x800AC472
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Shapes.Item(Object Index)
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn.ReplaceShapeInExcel(String strPath, String key, String strAlternativeText, String strGUID, String strErrorMessage)
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn._addInChart_DownloadComplete(Object sender, ICAddInEventArgs e)

    Is this a known issue with Excel 2016? Works fine when i have only one chart to refresh - means only one add shape and one delete shape operation.



    Thursday, October 15, 2015 2:27 PM

Answers

  • >>>Is this a known issue with Excel 2016? Works fine when i have only one chart to refresh - means only one add shape and one delete shape operation.

    According to your description, I have made a sample with your code, unfortunately, I can't reproduce your issue without Thomson.Reuters.Datastream.Charting.ICAddInManager dll.

    Based on the Stacktrace you have used Thomson.Reuters.Datastream.Charting.ICAddInManager dll that it is third-party dll, so I suggest that you could try to reproduce the issue with a standalone application or get the support from the Official support of third-party library.

    Wednesday, October 21, 2015 9:24 AM

All replies

  • We are doing the research about your problem. There might be some delay about the response. Appreciate your patience.
    Monday, October 19, 2015 9:38 AM
  • Thanks for looking into this - Just to add some more on it as experienced today on debug -

    Looks like PIA is losing its hold on underlying object sometimes..

    Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))


    Stacktrace:

    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Shapes.GetEnumerator()
    
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn.EnsureUniqueShapes() in C:\D\SVN\Eikon_CP\trunk\AddInManager\ExcelAddIn.cs:line 3448
    
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn.GetSelectedCharts() in C:\D\SVN\Eikon_CP\trunk\AddInManager\ExcelAddIn.cs:line 2057
    
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn.ReadShapeObjects_Excel(Object sender, DoWorkEventArgs e) in C:\D\SVN\Eikon_CP\trunk\AddInManager\ExcelAddIn.cs:line 1757
    
       at Thomson.Reuters.Datastream.Charting.ICAddInManager.ICExcelAddIn._readShapeWorker_DoWork(Object sender, DoWorkEventArgs e) in C:\D\SVN\Eikon_CP\trunk\AddInManager\ExcelAddIn.cs:line 2901

    Here On debug i can see that it is able to count no of shapes - But when i go for iteration to perform some operation I get the above exception.   

            private void EnsureUniqueShapes()
            {
                try
                {
                    List<string> shapeNames = new List<string>();
                    Excel.Worksheet WorkSheet = (Excel.Worksheet)oExcelApp.ActiveSheet;
                    Excel.Shapes theShapes = WorkSheet.Shapes;
                    bool duplicateExist = false;
                    foreach (Excel.Shape shape in theShapes)
                    {
                        if (shape.AlternativeText.Contains(Constants.CHARTXML))
                        {
                            if (shapeNames.Contains(shape.Name.ToLower()))
                            {
                                duplicateExist = true;
                                break;
                            }
                            shapeNames.Add(shape.Name.ToLower());
                        }
                    }
                    if (duplicateExist)
                    {
                        int iShapeNo = 1;
                        foreach (Excel.Shape shape in theShapes)
                        {
                            if (shape.AlternativeText.Contains(Constants.CHARTXML))
                            {
                                shape.Name = Constants.PICTURE + iShapeNo.ToString();
                                iShapeNo++;
                            }
                        }
                    }
                }
                catch
                {
                    throw;
                }
            }
    


    and trying to activate a sheet also fails

    ((Excel._Worksheet)oSheet).Activate();


    Monday, October 19, 2015 3:09 PM
  • >>>Is this a known issue with Excel 2016? Works fine when i have only one chart to refresh - means only one add shape and one delete shape operation.

    According to your description, I have made a sample with your code, unfortunately, I can't reproduce your issue without Thomson.Reuters.Datastream.Charting.ICAddInManager dll.

    Based on the Stacktrace you have used Thomson.Reuters.Datastream.Charting.ICAddInManager dll that it is third-party dll, so I suggest that you could try to reproduce the issue with a standalone application or get the support from the Official support of third-party library.

    Wednesday, October 21, 2015 9:24 AM