Skip to main content
Practice

Loading a PPT Template

Now, using the Excel data, we need to load the certificate template to create a slide for each recipient.

We'll learn how to use the python-pptx library to load a pre-prepared certificate template.

Loading the PPT Template
import openpyxl
from pptx import Presentation
from io import BytesIO
from pptx.enum.shapes import MSO_SHAPE_TYPE

# Load the PowerPoint file
presentation = Presentation("input_file.pptx")

# Print information of the first slide
first_slide = presentation.slides[0]

# Output placeholder information on the slide
for shape in first_slide.placeholders:
# Print placeholder text
if shape.has_text_frame:
print(f"placeholder: {shape.text}")

The code above loads information from the first slide and prints the placeholder information on the slide.

Output placeholder information on the slide
placeholder: <AWARD_NAME>
placeholder: <CONTENT>
placeholder: <NAME>
placeholder: <ORGANIZATION>

This way, we can load the information from the first slide of the PPT template and verify its contents.

We will use this template to add slides that reflect the recipient's information.

In the next lesson, we will cover the process of creating slides and filling in text based on the data loaded from the Excel file.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.