Free Support Forum -

Update the text values in the existing presentation

I am trying to update my existing presentation using Aspose.Slides java.
I am able to get the list of shapes but I am clueless as to how to update the text values.
Please help.

Welcome to our community! Thank you for your request. You can update a text of a shape as below:

if(shape instanceof IAutoShape)
    ITextFrame textFrame = ((IAutoShape) shape).getTextFrame();
    if (textFrame != null)
        textFrame.setText("my text");

More details: Manage TextBox, Manage Paragraph
API Reference: IAutoShape interface, ITextFrame interface

Thank you for the quick reply. I had tried this approach but the shape was of type OleObjectFrame so I was getting typecasting error.
Anyways I am able to update text using the code below:

        ITextFrame[] textFramesSlideOne = SlideUtil.getAllTextBoxes(slide);
        for (ITextFrame iTextFrame : textFramesSlideOne) {
            //Loop through paragraphs in current TextFrame
            for (IParagraph para : iTextFrame.getParagraphs()) {
                //Loop through portions in the current Paragraph
                for (IPortion port : para.getPortions()) {
                    //Display text in the current portion
                    port.setText("Text to Replace");

The OleObjectFrame class doesn’t implement the IAutoShape interface. In my code example, OleObjectFrame objects will be skipped without typecasting errors. But I’m glad you found the appropriate solution for your purposes.