G
Guest
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
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