Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AttributeError: 'SlideShapes' object has no attribute 'text_frame'

I am using python-pptx library for editing powerpoint presentation in python. But on running the below script:

from pptx import Presentation
prs = Presentation('path/to/presentation.pptx')
slide = prs.slides[0]
shape = slide.shapes
shape.text_frame.text = "Introduction"

the error that arises is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 3
      1 slide = prs.slides[0]
      2 shape = slide.shapes
----> 3 shape.text_frame.text = "Introduction"

AttributeError: 'SlideShapes' object has no attribute 'text_frame'

Here I am using python-pptx==0.6.21. Is there any method for the same?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Shouldn’t that be

shape = slide.shapes[0]

as it’s the first shape you want.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading