a way to test if Ungroup is possible?

T

Tony Logan

Is there a way to use code to detect whether an object can be ungrouped or
not?

I'm using a routine that I got from PPTools (www.pptfaq.com) as part of a
larger routine to do some PowerPoint processing via Word. Specifically, I'm
copying as much data as I can from all the shapes on all the slides in a
PowerPoint file, and pasting that data into a Word file.

However, if I add more shape types to the "Case Is" line in the routine
below (msoPlaceHolder is one that's been problematic), and if that particular
shape in my PowerPoint file can't be ungrouped, then the code will throw an
error that stops the routine. It doesn't even go into the error handler to
give me a chance to Resume Next.

So it seems the solution is to perform a test as to whether a particular
shape can be ungrouped or not, and only ungroup it if the test is true. But
if there's a way to do that, I haven't run across it in the Help files or
stumbled upon it while trying various bits of code. Does anyone know if this
is possible?

Here's the routine I mentioned earlier:

Sub EveryShapeOnSlide(oSl As Slide)
' Performs some operation on every shape on a slide

Dim oSh As Shape
On Error GoTo ErrorHandler

For Each oSh In oSl.Shapes
Select Case oSh.Type
Case Is = msoEmbeddedOLEObject, msoLinkedOLEObject, msoPicture
' Attempting to ungroup a bitmap image causes an error
' but no harm is done; we'll ignore it.
On Error Resume Next
oSh.Ungroup.Group
On Error GoTo ErrorHandler
Case Else
' ignore other shape types
End Select

Next oSh

NormalExit:
Exit Sub

ErrorHandler:
Resume Next

End Sub
 
T

Tony Logan

Hi, Steve. The error I get is "Run-time error 70. Permission denied." And
even though I've written an error handler, this error displays the dialog and
brings things to a grinding halt, rather than sending the error to the error
handler.

The line causing this error is:
oSh.Ungroup.Group

I've tried as many variations on this as I can think up, like
oSh.Ungroup.Select, for instance, but as soon as it gets to that line, the
routine stops.

It almost seems like I need to know whether a shape has the option to be
ungrouped before I make the attempt to ungroup it, but I'm not sure how to do
that in code.

Thanks.
 

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