[Python] python-pptx - Getting an unwanted slide at the start when using a custom template

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    The company I work for has a standard PowerPoint template. I'm trying to use this template with python-pptx. However, I'm getting an unwanted slide at the start of my slide deck and I can't figure out what I'm doing wrong.

    My first attempt was a simple:

    prs = Presentation('companyTemplate.potx')


    but this gave several errors.

    I then read the manual (yeah, I know) and realized I should have converted the .potx file into a standard PowerPoint .pptx file.

    My second attempt was:

    prs = Presentation('companyTemplate.pptx')


    This worked but my desired PowerPoint slide deck had the entire template PowerPoint at the start.

    At this point, I created a new, blank, PowerPoint using the default PowerPoint template and switched to Slide Master view.

    • I then opened the companyTemplate PowerPoint
    • Switched to Slide Master view in the companyTemplate PowerPoint
    • Copied the first "slide" in this Slide Master view to the open, blank, PowerPoint.
    • Deleted the original Slide Master from the new, blank, PowerPoint
    • Closed the Slide Master view
    • Saved this newly-modified PowerPoint as my new companyTemplate.pptx file.

    This works but, as noted at the start, I'm getting a single unwanted slide at the start of my desired slide deck.

    It's easy enough to delete this unwanted slide but I'd like to keep it from appearing in the first place.

    When I use the default presentation in python-pptx, I don't get an unwanted slide at the start, so I figure there has to be a way to do what I want. I just can't figure out how.

    For what it's worth, the unwanted slide is the last "slide" in Slide Master view, and is labeled "Blank". It's also the slide that appears if I open my own personal companyTemplate.pptx PowerPoint file.

    Continue reading...

Compartilhe esta Página