# PPT: Ungroup all objects macro - groups within groups issue



## abalieu (Nov 2, 2016)

Hi all,

I'm trying to put together a little code that will ungroup every object within every slide in a presentation. So far I have the code below, but it only ungroups the first 'layer' of groupings. I see two solutions for all grouped objects to ungroup:

1) Loop through the code (maybe 5 times?) to ensure everything is ungrouped
2) Add a flag to grouped objects and keep looping until all flags are cleared?

In either of my solutions, I'm totally stuck as to how to write this, so any help is appreciated!

Thanks in advance!
Alex.


----------



## abalieu (Nov 2, 2016)

Now actually with the code:

[FONT=&quot]Sub Ungroup_all()[/FONT]
[FONT=&quot]Dim oSh as Shape[/FONT]
[FONT=&quot]Dim oSl as Slide[/FONT]

[FONT=&quot]For Each oSl in ActivePresentation.Slides[/FONT]
[FONT=&quot]For Each oSh in oSl.Shapes[/FONT]
[FONT=&quot]Select Case [/FONT][FONT=&quot]oSh.Type[/FONT]
[FONT=&quot]Case Is = msoGroup, msoTable, [/FONT][FONT=&quot]msoEmbeddedOLEObect [/FONT]
[FONT=&quot]oSh.Ungroup[/FONT]
[FONT=&quot]End Select[/FONT]
[FONT=&quot]Next[/FONT]
[FONT=&quot]Next[/FONT]
[FONT=&quot]End Sub[/FONT]


----------



## abalieu (Nov 2, 2016)

I've actually solved this myself 

Sub Ungroup_all()

Dim oSh As shape
Dim oSl As slide
Dim x As Long


For x = 1 To 10
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
Select Case oSh.Type
Case Is = msoGroup, msoTable, msoEmbeddedOLEObect
oSh.Ungroup
End Select
Next
Next
Next x


End Sub


----------

