Edit PPT in Python

Add text, shapes, and other presentation elements to PPT files with Python

Edit PPT using Aspose.Slides

Aspose.Slides for Python via .NET lets you load PPT presentations, edit their slides, and save the changes without Microsoft PowerPoint. You can modify text and shapes or add new presentation elements programmatically.

Edit PPT in Python

The following example opens a PPT presentation, adds a text-bearing shape to its first slide, and saves the edited presentation as a new PPT file.

Python code for editing PPT

with slides.Presentation("presentation.ppt") as presentation:
    slide = presentation.slides[0]
    text_shape = slide.shapes.add_auto_shape(
        slides.ShapeType.RECTANGLE, 10, 10, 300, 50)
    text_shape.text_frame.text = "New text"

    presentation.save("edited-presentation.ppt", slides.export.SaveFormat.PPT)

How to edit PPT in Python

  1. Install Aspose.Slides for Python via .NET by following the installation guide .

  2. Open the source PPT file with Presentation.

  3. Access the target slide through a slide variable.

  4. Call ShapeCollection.add_auto_shape to add a rectangle to the slide.

  5. Set the shape’s text_frame.text value.

  6. Call Presentation.save with SaveFormat.PPT to write the edited presentation.

Edit other files

You can also edit files in other formats