[Python] Python PPTX Slide Layout Import

Discussão em 'Python' iniciado por Stack, Agosto 24, 2025.

  1. Stack

    Stack Membro Participativo

    I apologize, I have been looking for a solution but can't find enough documentation to figure it out. I am trying to import a default slide layout required for school, it has a special background and a Title Block and a Subtitle Block. I assumed when I import this, python-pptx would just automatically create placeholders 0 and 1 for those two text blocks but when I try and edit the placeholders, I get an attribute error:

    AttributeError: 'Presentation' object has no attribute 'placeholders'


    My code is as follows:

    from pptx import Presentation
    prs = Presentation('SeniorDesignTitleSlide.pptx')

    Presentation_Title = prs.placeholders[0]
    Presentation_Subtitle = prs.placeholders[1]
    Presentation_Title.text = 'This Is a Test'
    Presentation_Subtitle.text = 'Is This Working?'

    prs.save('SlideLayoutImportTest.pptx')


    Edit[0]: I do realize I am just opening that particular presentation, but how do I access and edit the single slide that’s in it ?

    Edit[1]: I’ve found a few posts from 2015 about python-pptx expanding on this feature, but there’s no further information that it actually occurred.

    How does python-pptx assign placeholders for imported slide layouts? Or does it even do this? Does it need to be a .potx file?

    Thank you in advance.

    Continue reading...

Compartilhe esta Página