Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / March 2008

Tip: Looking for answers? Try searching our database.

Determining whether a PPT shape has other shapes within it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dale Fye - 21 Mar 2008 21:28 GMT
I'm trying to write some code that will enumerate all of the shapes on  a
slide.

Got this part working for the top level shapes, but if a shape is Group or a
diagram, or something else, how do I determine whether it has shapes
imbedded within it, and if so, how do I iterate through the shapes within
that higher level shape?

Dale
vindys - 21 Mar 2008 21:49 GMT
Dim s As Shape
Set s = ActiveWindow.Selection.ShapeRange(1)
If s.Type = msoGroup Then
   With s
       For i = 1 To s.GroupItems.Count
           's.GroupItems (i) will give you each item
       Next i
   End With
End If

> I'm trying to write some code that will enumerate all of the shapes on  a
> slide.
[quoted text clipped - 5 lines]
>
> Dale
Dale Fye - 21 Mar 2008 22:05 GMT
Will this work for all types of shapes that have other shapes imbedded
within them, or only "Groups"?

> Dim s As Shape
> Set s = ActiveWindow.Selection.ShapeRange(1)
[quoted text clipped - 16 lines]
>>
>> Dale
Steve Rindsberg - 22 Mar 2008 05:16 GMT
> Will this work for all types of shapes that have other shapes imbedded
> within them, or only "Groups"?

Only Groups have other PPT shapes embedded within them; embedded OLE objects,
linked OLE objects and some pictures are embedded as WMF/EMF representations
that turn INTO shapes when ungrouped.  As a general solution, you'd have to
ungroup them to get at the component shapes.

> > Dim s As Shape
> > Set s = ActiveWindow.Selection.ShapeRange(1)
[quoted text clipped - 16 lines]
> >>
> >> Dale

Signature

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com

================================================
Dale Fye - 22 Mar 2008 13:03 GMT
Steve,

Vindy's code below helped me crack the nut for Group types 8 and 13 and
appears to handle part of the issue with shape type (14, Diagram 4).

However, with the Diagram shape, although that code did allow me to delve
into the diagram, it did not identify the types of shapes that were embedded
in the diagram, and when I went into PPT and clicked on the diagram, there
did not appear to be a way to ungroup the shapes that make it up, to give me
access to the individual shapes.

I would be interested in knowing how to do this, as well as how to ungroup
embedded OLE Objects.

Once ungrouped, I can always close the presentation without saving the
changes, but I need to be able to diassemble the entire presentation so that
I can look at each of it's component parts.

Thanks for your help

Dale

>> Will this work for all types of shapes that have other shapes imbedded
>> within them, or only "Groups"?
[quoted text clipped - 36 lines]
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 25 Mar 2008 03:46 GMT
> However, with the Diagram shape, although that code did allow me to delve
> into the diagram, it did not identify the types of shapes that were embedded
> in the diagram, and when I went into PPT and clicked on the diagram, there
> did not appear to be a way to ungroup the shapes that make it up, to give me
> access to the individual shapes.

This should do it, I think:

Dim oSh As Shape
Dim x As Long

' for demo purposes, assume you've selected a diagram
Set oSh = ActiveWindow.Selection.ShapeRange(1)

With oSh
   For x = 1 To .GroupItems.Count
       Debug.Print .GroupItems(x).Name
       ' deal with other properties here
   Next
End With

> I would be interested in knowing how to do this, as well as how to ungroup
> embedded OLE Objects.

And something like his for the latter.  The odd loop is because some object
when ungrouped turn into a PPT group.

Sub UngroupOLEObject()

Dim oSh As Shape
Dim oShapeRange As ShapeRange
Dim x As Long

' assume you've selected an ole embedded or linked object
Set oSh = ActiveWindow.Selection.ShapeRange(1)

Set oShapeRange = oSh.Ungroup
Do Until oShapeRange.Count > 1
   Set oShapeRange = oShapeRange.Ungroup
Loop

With oShapeRange
   For x = 1 To .Count
       Debug.Print .Item(x).Name
   Next
End With

End Sub

> Once ungrouped, I can always close the presentation without saving the
> changes, but I need to be able to diassemble the entire presentation so that
[quoted text clipped - 44 lines]
> > PPTools:  www.pptools.com
> > ================================================

Signature

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com

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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.