Problem reading text from a rectangle shape

I’m trying to replace text in shapes. It works fine, but I’m having problems if the shape is a rectangle. Then the TextFrame.Text property is empty and I cannot see texts in the Paragraphs as well.

How can I access the text of a rectangle shape properly?

My current code:

        var textHolders = shapes.Where(i => i.GetType() == typeof(AutoShape)) as IEnumerable<IShape>;

        if (textHolders != null)
        {
            foreach (AutoShape shape in textHolders)
            {
                if (shape.TextFrame.Text.Contains("<$version$>"))
                {
                    shape.TextFrame.Text = shape.TextFrame.Text.Replace("<$version$>", "V0.1");
                }
                if (shape.TextFrame.Text.Contains("<$copyright$>"))
                {
                    shape.TextFrame.Text = shape.TextFrame.Text.Replace("<$copyright$>", "2018");
                }
            }
        }

@tschissler,

I have observed the requirement shared by you and request you to please share the working sample code along with source presentation. Please also identify to us that which Rectangle shape in your presentation is not getting accessed. Can you make sure if that particular rectangle shape has text inside it or not?

OK, I found the problem. The text started with an equation and this seems to cause the issue that the whole text property is empty. Removing the equation and having only the rest of the text works now.

Thanks
–Thomas–

@tschissler,

It’s good to know that you have been able to resolve the issue on your end. If there is still an issue then please feel free to share with us.