Reputation: 953
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.
Upvotes: 2
Views: 3825
Reputation: 28883
PowerPoint 2010 and later has the concept of section as a way to organize the slides in presentation:
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.
Upvotes: 4
Reputation: 1591
I recommend checking out the python-pptx documentation for opening and parsing presentations. It will allow you to iterate over all slides in that presentation. As you're looking for section slides only, you can use the slide_layout
attribute of each slide which consists of a slide_master
attribute that describes the layout which was used as a basis to filter for section slides. In the slide, you could then iterate over all shapes in a given slide. You can use the shape_type
attribute to find the appropriate shape - in this case, it would be text box as described here which consists of a text
attribute.
Upvotes: 1