Adding Text to autoshape

I’m having some issue writing text to a slide, i’m doing the following but when I open the new presentation the slide is corrupted.

foreach (ShapeEx shape in newSlide.Shapes)
{
if (shape is AutoShapeEx)
{
((AutoShapeEx)shape).AddTextFrame(“Test Text”);
break;
}
}

any ideas?

Hi,

The code provided by you is working perfectly on my end. Please check your source pptx.