Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you change the Placeholder type using python-pptx?

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!

like image 384
mcdevitts Avatar asked Nov 08 '17 22:11

mcdevitts


People also ask

What is placeholder in Python Pptx?

A placeholder can be also be used to place a rich-content object on a slide. A picture, table, or chart can each be inserted into a placeholder and so take on the position and size of the placeholder, as well as certain of its formatting attributes.

Which modification can be done to placeholder in a PowerPoint slide?

Select the placeholder, and then drag it to its new location. Select the placeholder, click the Format tab, and then make the changes that you want. For example, to change the fill color of the placeholder, under Shape Styles, click Fill.

How do you create a placeholder in Python?

The placeholder is defined using curly brackets: {}.


1 Answers

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).

like image 193
scanny Avatar answered Oct 09 '22 16:10

scanny