pythonxmlpowerpoint

python-pptx - How to access presentation section titles programmatically?


In Powerpoint, I'd like to create agenda / table of content slides, with section titles serving as input to these agenda slides. Sections allow one to structure a presentation document. They are particularly useful in the slide-sorter and outline mode. Conveniently leveraging section titles for the purpose of constructing an agenda slide is a feature of PowerPoint add-ons often found in consulting (Slideproof, Think-Cell,...). The goal is to change one section title, and have this change reflected on all agenda slides -- without having to touch each and every agenda slide.

Is there a way to access these section titles programmatically, ideally using python-pptx? So far I have tried reading the contents of a sample pptx file with unique section titles. Unfortunately, no success in finding the identical section titles in the pptx file when grepping through the file contents.


Solution

  • PowerPoint 2010 and later has the concept of section as a way to organize the slides in presentation:

    https://support.office.com/en-us/article/Organize-your-slides-into-sections-de4bf162-e9cc-4f58-b64a-7ab09443b9f8.

    These section objects are distinct from a slide and appear in slide-sorter and outline mode. I would characterize them as primarily an authoring feature as they don't directly appear in presentation mode.

    This is in contrast to the notion of a segue (pronounced seg-way) slide, which is simply a slide having only a title, often vertically centered, that "punctuates" the sequence of slides into meaningful groups. These can be (but are not necessarily) based on a particular slide layout for that purpose, perhaps named "Section Header" or "Segue Slide".

    python-pptx doesn't yet have API support for the section concept. However, if you just mean using seque slides, then the approach suggested by m_____z is the way to go.