My PowerPoint slide has a number of group shapes in which there are child text shapes.
Earlier I was using this code, but it doesn't handle Group shapes.
for eachfile in files:
prs = Presentation(eachfile)
textrun=[]
for slide in prs.slides:
for shape in slide.shapes:
if hasattr(shape, "text"):
print(shape.text)
textrun.append(shape.text)
new_list=" ".join(textrun)
text_list.append(new_list)
I am trying to extract the text from these child text boxes. I have managed to reach these child elements using GroupShape.shape But I get an error, that these are of type 'property', so I am not able to access the text or iterate (TypeError: 'property' object is not iterable) over them.
from pptx.shapes.group import GroupShape
from pptx import Presentation
for eachfile in files:
prs = Presentation(eachfile)
textrun=[]
for slide in prs.slides:
for shape in slide.shapes:
for text in GroupShape.shapes:
print(text)
I would then like to catch the text and append to a string for further processing.
So my question is, how to access the child text elements and extract the text from them.
I have spent a lot of time going though the documentation and source code, but haven't been able to figure it out. Any help would be appreciated.