Ungroup - Permission Denied

J

John Svendsen

Hi All,

I've tried running the Help ungroup example, but VBA complained with a Run
time error '70' - Permission denied
Does someone have an idea what's up?

Tks, JS

=======================================

Ungroup Method Example . This example ungroups any grouped shapes and
disassembles any pictures or OLE objects on myDocument.
Set myDocument = ActivePresentation.Slides(1)
For Each s In myDocument.Shapes
s.Ungroup
Next
 
S

Steve Rindsberg

Hi All,

I've tried running the Help ungroup example, but VBA complained with a Run
time error '70' - Permission denied
Does someone have an idea what's up?

Yep. It's bad code.

It's trying to ungroup every shape whether it's a group, OLE object or not.
Try to ungroup something ungroupable like a rectangle and you get that error.

Easiest way out: tell it to ignore the errors:

Set myDocument = ActivePresentation.Slides(1)
On Error Resume Next
For Each s In myDocument.Shapes
s.Ungroup
Next

And it only works on Slide 1.

This might be more useful if you want to do the whole presentation and only
ungroup the embedded OLE stuff:

Sub ThisWayIsBetter()

Dim oSl as Slide
Dim oSh as Shape

For Each oSl in ActivePresentation.Slides
For Each oSh in oSl.Shapes
If oSh.Type = msoEmbeddedOLEObject Then
oSh.Ungroup
End if
Next ' Shape
Next ' Slide

End Sub
 
S

Shyam Pillai

John,
The help example is wrong. You can ungroup only those shapes which can be
ungrouped (group, OLE object, Cliparts etc)
If you want to persist with the same code, add the following line prior to
your code.

On error resume next
Set myDocument = ActivePresentation.Slides(1)
For Each s In myDocument.Shapes
s.Ungroup
Next

Alternately, you should check each shape for it's type and then ungroup as
applicable.
 
E

Echo S

John, since Shyam and Steve are saying that the Help example is wrong, can
you tell us what version of PPT you're using and how you located that Help
file (e.g., searched for Ungroup in the Help box in PPT 2003) so we can try
to get it corrected?

Thanks!
 
S

Shyam Pillai

Echo,
It's easily located exactly as you stated. Searched for Ungroup method in
the PPT VBA help box and the description of the method as well as the
incorrect example popups up.


--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how


Echo S said:
John, since Shyam and Steve are saying that the Help example is wrong, can
you tell us what version of PPT you're using and how you located that Help
file (e.g., searched for Ungroup in the Help box in PPT 2003) so we can
try
to get it corrected?

Thanks!
--
Echo [MS PPT MVP]
http://www.echosvoice.com


John said:
Hi All,

I've tried running the Help ungroup example, but VBA complained with
a Run time error '70' - Permission denied
Does someone have an idea what's up?

Tks, JS

=======================================

Ungroup Method Example . This example ungroups any grouped shapes and
disassembles any pictures or OLE objects on myDocument.
Set myDocument = ActivePresentation.Slides(1)
For Each s In myDocument.Shapes
s.Ungroup
Next
 
S

Steve Rindsberg

John, since Shyam and Steve are saying that the Help example is wrong, can
you tell us what version of PPT you're using and how you located that Help
file (e.g., searched for Ungroup in the Help box in PPT 2003) so we can try
to get it corrected?

What Shyam said. In PPT 2003's VBA editor, search for help on UNGROUP. Click
the Example link.

Same doofus example in PPT2000 and I'd assume everything else in between.

Looks like it was haphazardly adapted from a Word example (why set a myDocument
reference to a slide rather than a PPT document otherwise? Duh.)
 
E

Echo S

Ah, thanks.

I don't know how much luck we'll have getting it fixed in the VBA help, but
we can at least pass it along.

Echo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top