Basics of Python PowerPoint automation


Following the articles on using Microsoft Excel smarter, I received several messages expressing interest in this topic and wishing to share more information about other office products. This stimulated me to create a series of articles on office tips. The first article is about Microsoft PowerPoint. This article will teach you about

Learn all about powerpoint presentation automation, from top experts

Modifying the slide by inserting images and changing words.

The methods for generating slides in different formats, such as PNG and PDF.

You can also check out my articles on Microsoft Excel by clicking the links below.

Why do you need to use Automation in PowerPoint?
Suppose that you are facing a situation where you have to continuously submit the same presentation over and over again after updating the data according to the current format and statistics. And this process can continue month after month without holding back. The situation can also be a bit different for you where you will have to make the necessary changes that will be apt for the target audience, their market standards, business line, industry and product. Although the tools are available to make those necessary changes, the entire situation is as simple as it seems on paper. learn all the Basics of Python PowerPoint automation

Now manually updating all those slides every day can be a tedious task. Moreover, the process itself is very slow and time-consuming at the same time. The whole presentation remains the same, but the data and information change and keep on updating. That is the reason why you need an automation software which can do all that work without any errors.


Many people have to update the PowerPoint slides regularly and frequently as part of their daily work. This includes the date, table figures, KPI statistics, etc. These tedious tasks can be very annoying and take up to 30 minutes each day.

The following example assumes that we have a regular update of currency exchange prices. We will pop up the currencies with the greatest changes. We are required to show trending prices for those having the highest percentage changes. best ways to learn  python powerpoint automation, 

Step 1 — Define the Corresponding components

We must first decide which elements we will be updating. Let’s take my slide for an example. There are 7 areas that need to be updated.

Last update date time

Top 5 Table

Table 5: Bottom Five

Top figure label

Bottom figure label

A figure of the Year

Bottom figure

Step 2 – Data Preparation

Once you have identified the components that need to be updated, the next step would be to determine the data source. The data source can be either extracted from the SQL server, received from an email, or from a general office computer. We will show you how data can be scraped from the Internet. As an example, we will use Yahoo Finance data.

Since this is not the main topic of the article, I won’t go into detail about how data is scraped. It’s really just two lines of code. We first get the page by using requests. Next, we use pandas to extract the table. We have also saved the scraping date and time for future use. Basics of Python PowerPoint automation

Only the plots are left. Follow the codes below to generate your plot. Don’t worry! It will be easy to follow as I will go through each step.

Get the latest data on the currency exchange rate.

Take the closing price and plot it in a line graph.

The plots should be formatted in a way that aligns with the PPT theme, such as color, font size, or transparent background.

You can save the plots for PNG.

1. Get the data

You can find the price series data for a specific currency exchange rate at this link. Only one parameter is required, and that is the name of the currency exchange rate.

2. The line chart can be plotted

The price list can be obtained by checking the dictionary structure. One thing I want to mention is that I did a check here to get rid of the None data from the price list because I discovered some missing data.

3. Stylize this chart

To polish the plots, I made a few changes.

For the Date, remove the ticks from the x-axis.

You can change the font size or color of the y-axis ticks.

Make the line wider by changing the border color

4. The plot can be saved

The figure is saved as a PNG file. You only need to indicate transparent=True to make the background transparent.

Step 3 – PowerPoint Update

This is our current focus. You will need the python pptx package before you can use Python to edit PowerPoint. You can install it by typing the following code into the terminal.

It seems so complicated and long. Don’t panic. You can understand the structure and handle it easily.

Please specify the slide that you are working on.

Take away the plots that are already there.

Add new plots.

Define the shape index of the components.

Each component should be updated one at a time.

Export the PowerPoint into any format you prefer

1. Load the PowerPoint and enter the slide

You can see the number 0, in brackets, from the code above. It is the slide number. Because I am working on the slide number, I specify 0. If your regular update slide is slide 10, you will need to indicate the number 9.Basics of Python PowerPoint automation

2. Take out the old plots

We have already defined the 7 components in Step 1. There are now two plots, component 6 and component 7. We must first delete them in order to replace them. The new plots may be overlapped with existing plots. The problem is, “How do we specify which items are in each slide?”

Different shapes can be used for different objects in python pptx. The following code will allow you to check what shapes are in your slide.

Related Articles

Back to top button