[Python] python-pptx - Adding the content box in a "Title and Content" slide

Discussão em 'Python' iniciado por Stack, Abril 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the pptx module to create a PowerPoint "Title and Content" slide.

    prs = Presentation()
    mySlide = prs.slides.add_slide(prs.slide_layouts[1])


    I can "address" the title with either "title" attribute or the "placeholder[0]" attribute.

    # These both work.
    titlePlaceholder = mySlide.shapes.title
    titlePlaceholder = mySlide.shapes.placeholders[0]


    However, the only way I can figure out to "address" the "content box" on the "Title and Content" slide is with the "placeholder[1]" attribute.

    contentPlaceholder = mySlide.shapes.placeholders[1]


    Is there another way to "address" the content box? Is there something like a "content" attribute?

    # I'd like to use something similar to this.
    contentPlaceholder = mySlide.shapes.content


    Incidentally, my apologies in advance for any typos in my code examples. For corporate reasons, I can't access StackOverflow on the same system I do my Python programming, so I can't cut-and-paste.

    Continue reading...

Compartilhe esta Página