0

Is there a way to ungroup grouped images within the PowerPoint slide using Python? Or is there a way that I can make such a function on my own?

Testing through powerpoint 2007 version. Thank you.

I would like to inquire after confirming that the python-pptx module does not have the above function.

PYS
  • 1

1 Answers1

0

I haven't figured a way of doing so without damaging the XML but if you are OK with clicking repair once you open the PowerPoint file this does the trick...

import pptx
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE    

presentation = Presentation("GROUP.pptx")

for slide in presentation.slides:
    for shape in slide.shapes:
        if shape.shape_type == MSO_SHAPE_TYPE.GROUP:
            group = shape.element
            parent = group.getparent()
            index = parent.index(group)
            for member in group:
                parent.insert(index, member)
                index += 1
            parent.remove(group)
            
presentation.save("UNGROUP.pptx")
Luke Bowes
  • 292
  • 2
  • 7