Iterate through selected shapes and their children ...

M

Martin Stender

Hi all,

I need to iterate through what-ever-many shapes are selected on a slide
in layout mode.

Specifically, I need to see if their background colors (fill.forecolor)
matches or not.

But in order to keep my sanity, (since there are tons of combinations)
I was hoping to figure out how to do this recursively.

But I can't find out how to treat a table as a bunch of grouped shapes
(as they really are, or? ), and I have still to figure out a way to
detect if a group also contains tables etc.

Before we get into the nitty-gritty, I just wanted to ask:
Is this at all possible in VBA?

Also, I grabbed an event handler from Steve Rindbergs site (thanks
Steve :)), but for some reason, it doesn't respond/fire when you
change your selection of entire table-columns within the same table.
Is that a shortcoming within PPT itself, or are there other ways of
detecting selections?

Thanks in advance
Martin
 
B

Brian Reilly, MVP

Martin,
Yes, this is all available in VBA.

I'll paste in a routine that iterates through all shapes on all
slides. You'd want to change the internal code which is marked to
check for the .type and deal with it in a Select Case statement with
proper coding for each type. Watch out for line breaks here. There's
also a copy on my web site which you could copy and paste into a
module at http://reillyand.com/Support Pages/sub_iterate.htm

Brian Reilly, MVP

Sub Iterate_Through_All_Shapes_And_Read_Tags()

'PURPOSE: Refers to EACH object on EACH page and checks for a tags
..name
'Then if it is a StickyStyle Name
'Developer: Brian Reilly January 2001
Dim iShape As Integer
Dim iSlide As Integer
Dim iTags As Integer


For iSlide = 1 To ActivePresentation.Slides.Count
With ActivePresentation.Slides(iSlide)
For iShape = 1 To
ActiveWindow.Presentation.Slides(iSlide).Shapes.Count
'No need to select the object in order to use strShape

With
ActiveWindow.Presentation.Slides(iSlide).Shapes(iShape)
'''''''''''Substitute whatever code to the End of Substitute
For iTags = 1 To .Tags.Count

If .Tags.Name(iTags) = "STICKYSTYLE" Then
MsgBox "The shape " &
ActiveWindow.Presentation.Slides(iSlide) _
.Shapes(iShape).Name & " has a
Tags.Name of " & Chr(13) _
& .Tags.Name(iTags) & Chr(13) _
& "and has a Tags.Value of " &
Chr(13) & .Tags.Value(iTags)
''PROCEED WITH NEXT TAG AND NEXT OBJECT
End If

Next iTags
End With

''''''''''''End of Substitute
Next iShape
End With
Next iSlide

End Sub
 

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