none
C# powerpoint SmartArt Node TextFrame2.TextRange.Text Setting Text Returns Error RRS feed

  • Question

  • I am trying to replace smartart node text and I get an error when trying to edit any part of the node.

    shp.SmartArt.AllNodes[1].TextFrame2.TextRange.Text = "string";

    Error Code:

    System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

    It may have to do with permissions to the node or visibility but I also am editing text with TextFrames with no problems. It only has to do with smartart nodes.

    shp.TextFrame.TextRange.Text = "string";

    I have tried frameworks 4.6 and 4.5 nothing seems to work when editing the node text. I also am directly calling the Microsoft.Office.Interop.PowerPoint.Application and Microsoft.Office.Interop.PowerPoint.Presentation with no usings. I am able to read the text but not set the text. I also am using office 16 .net core as well.

    I have office 2019 so that may also be the problem.


    Tuesday, December 31, 2019 3:40 PM

All replies

  • I got same problem with SmartArt.

    I solved this problem by changing

    .TextFrame2.TextRange.Text

    to

    .Shapes.TextFrame2.TextRange.Text

    Please try below one.

    shp.SmartArt.AllNodes[1].Shapes.TextFrame2.TextRange.Text = "string";

    Tuesday, March 31, 2020 5:59 AM