Skip to content Skip to sidebar Skip to footer

Get The Title Of Slides Of Pptx File Using Python

I am trying to get the title of each slide of a powerpoint file using Python. I am using Presentation package in Python but I couldn't find anything that specifies the titles. I ha

Solution 1:

This is my Answer :

from pptx importPresentationfilename=path_of_pptxprs= Presentation(filename)

for slide in prs.slides:
    title = slide.shapes.title.text
    print(title)

Input:

enter image description here

Output:

Hello, World!
Hello, World2!
Hello, World3!

Solution 2:

To build on @eyllanesc's answer, as @scanny points out, slide.shapes.title is a placeholder.

This means you can access the title text like:

from pptx import Presentation

prs = Presentation(ppt_filename)

slide = prs.slides[0]
slide.shapes.title.text = 'New Title'print('New Title is:')
print(slide.shapes.title.text)

And also change any other of the title placeholder properties such as:

slide.shapes.title.top = 100slide.shapes.title.left = 100slide.shapes.title.height = 200

Post a Comment for "Get The Title Of Slides Of Pptx File Using Python"