4
votes

I am generating new slides using python pptx and I see no way to update the slide number. I have set the footer in master layout but when I try to read the shapes, I don't see that component over there.

My code:

from pptx import Presentation

prs = Presentation('sample_ppt.pptx')
title_slide_layout = prs.slide_layouts[14]
slide = prs.slides.add_slide(title_slide_layout)

for shape in slide.shapes:
    print(shape.name)
prs.save('hh.pptx')
1

1 Answers

3
votes

This is a common confusion, possibly because the way PowerPoint handles footers is, well, confusing :)

The short answer is that you need to put a plain-textbox shape (not a footer placeholder) on the master slide, and insert into that textbox a slide-number field, using Insert > Slide Number from the menu. On the master, it will appear something like <#>, but on the slide that inherits from that master, it will appear as the slide number.