PPT: Ungroup all objects macro - groups within groups issue

abalieu

New Member
Joined
Nov 2, 2016
Messages
3
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.
 
Last edited by a moderator:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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]
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,805
Messages
6,174,722
Members
452,577
Latest member
Filipzgela

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top