Automating powerpoint creation

Mark McCracken
5 min readAug 15, 2022

--

Do you ever have to create complex powerpoints that look almost exactly the same on a regular basis? Do you find it boring? Do you wish you could make it easier? Well this is the post for you!

  • Why?
  • How?
  • Show me!

Why? tons of reasons, but here are 2 obvious ones:

  • At work, I give a regular weekly status update. Slides always the same, but different content in the slides.
  • Outside of work, I sometimes run a pub quiz at Neighbourhood bar in my local area. The quiz usually has the same popular format, but different questions every week. Otherwise it would get boring.

But actually creating these slides can be incredibly tedious, and powerpoint isn’t the best of formats for the “source” of questions. I wanted to save some effort, and guarantee consistency, so I decided to automate it.

How? Have a starting template, some filler content, and some python.

How do I make a template?

Normally, you’ll already have a powerpoint that you’ve used before, so take that, and make some template slides, in the master layout, by clicking View > Slide Master.

Slide master is a mode you enter and leave, so it presents different slides down the left when doing this, from your actual presentation.

I’ve got 100+ slides in a presentation here, but really only about 13 different kinds of slides. So take a slide you’ve already got, and replace normal text boxes with placeholders:

You can also do this for pictures and media. At work, this might be a text update of the latest status, and screenshots of a product, or visual representation of status. For the quiz, this is basically a slot to put a question. You can also add animations to these master slides, meaning you don’t need to faff around making it look nice after you’ve filled in the template. However, all the template animations need to happen first before you add anything specific to an implementation of that template, so something to bear in mind.

Lastly, you want to close Slide Master mode, and delete any actual slides which are filled in, leaving you with a template file that has template slides but no actual slides:

So you’ve got a template ready to fill? Great, but what to fill it with?

Next up, you need a way to store your content. Mostly, it’s just fairly simple files on the file system, or content from excel. My pictures just go in a folder, structured questions and answers in excel:

I’ve got a tab for each text-based quiz round:

But this could just as easily be content for a status update. Feel free to add conditional formatting for whatever makes it easier to input.

Next up, some pictures, same drill, just a placeholder. Keep it simple, let’s have the answer as the filename

Lastly, the sounds have their own folder, with everything consistently named:

You’ve got a template, and content to fill it with. How do you fill it?

Python time 🐍. Let’s get a basic program structure going:

So we’re able to make some basic slides, and understand the overall structure of the program. Let’s get into something more specific, updating some placeholder content:

Translates our template like so:

What about dynamically generating an unknown number of slides? We’ve got one slide for a whole round of questions, but one slide per answer. So let’s see some code for that:

Makes a single slide, updating each of the template boxes, then a new slide for each of those answers:

What about images and audio? Let’s take a look:

This checks each of the folders, and creates an object with the relevant links and content, and also moves a few items. Typically an audio file shows up as a little speaker icon, but I wanted that off screen, so set the position to be elsewhere. Got a slide each for question and answer:

And that’s pretty much it! Running this entire python file, only 170 lines, spits out a highly repeatable powerpoint, where I only need to find some questions and change my excel, to generate this with confidence.

There are a few tiny aspects which can’t be automated, for example, the audio needs to be animated for each slide to start immediately, but this is a 60 second job. Some of the images I manually grab from t’internet and paste in, but those are the last minute non-essential touches.

Check out the entire codebase here: https://github.com/Mark-McCracken/Quiz-Powerpoint-Generator

Hope this helps for any very dull powerpoint creations you’ve got!

--

--