8

The standard layouts for Powerpoint appear to have "Content" placeholders which appear as the type SlidePlaceholder. Is there a way to change these placeholders to another type? For example, I would really like to insert a picture into one of these placeholders, but SlidePlaceholder does not have an insert_picture method.

A previous question already addressed how to insert a picture, but the response mentioned:

You'll have to replace any "general purpose" content placeholder with one specific to what you're going to insert.

However, he didn't indicate how one would do this. And it isn't readily apparent from the documentation. Thanks for any help on this!

mcdevitts
  • 83
  • 1
  • 3

1 Answers1

3

You would make this change, by hand, using the PowerPoint application, in the "template" presentation you were starting with.

The placeholder would be in one of the slide layouts (View > Master > Slide Master from the menu in my version), and would be "cloned" into any new slides created from that layout.

I don't believe the PowerPoint UI offers a way to actually change the type of an existing placeholder in a slide layout, so you'd need to remove any existing one, if present, and create a new one of the same size at the same position (or wherever and however big you want).

scanny
  • 26,423
  • 5
  • 54
  • 80
  • 1
    Thanks for the reply scanny. One question: since I can add tables, images, etc. to the Content placeholders in the PowerPoint application, why can't I add them through python-pptx? It makes for fairly unintuitive distinction between the application and the python-pptx library. – mcdevitts Nov 09 '17 at 04:08
  • 1
    It was purely a decision based on development effort as I recall. There's no reason a "Content" (multi-content-type) placeholder couldn't be supported, it's just a substantial amount of additional code to make it happen and no one has stood up yet to sponsor it (or contribute it). It's not terrifically surprising I suppose, given that most folks, like you, know what they want to put in there (chart, table, picture), so don't need flexibility and have control over the starting template. It might come in a later version. – scanny Nov 09 '17 at 04:26
  • Okay thanks. I saw a pull request related to this on github a few years back, but it looks like you were waiting for unittests? – mcdevitts Nov 09 '17 at 04:53
  • Probably a lot more than that. I'd have to look, but most PRs only cover a small fraction of what needs to be done for a feature that's robust enough to be merged. – scanny Nov 09 '17 at 04:55