Re: Create array based on shape name or tag

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sorry, I must have misread your post. I'm glad that Like works for you.
I've never used it in PowerPoint, so I learned something new.

Unfortunately, I've never done quite what your doing (grouping from an
array) so I'm not sure how it will work, but you seem to know that part.
I'm not sure if you will have to Dim the array to the right size. If you
know how many items meet your criteria, you could Dim it in advance. If
you don't, you could run through your loop twice. The first time, you
could count how many items. Then, use Redim to set the size of your
array. Then loop through again and fill your array. This is assuming that
you actually need to know the size of the array, and I'm not sure you do.

If you are working in Normal View, you could select each object and group
the selection instead of trying to build an array.

Good luck. I wish I had a few minutes to play with this and give you more
specific advice, but I don't right now.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?TGlzYQ==?= <Lisa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:71FD50BF-B0F9-49F6-95FB-2BD8ED6EB977@xxxxxxxxxxxxx:

Thanks for the response, David...
Fortunately, the Like thing does seem to work in PPT... For example
see below.

My problem is figuring out how to put the items that meet the Like
criterion into an array so I can group them... Or group them somehow
(I'm not married to the "array" notion, it's just my best guess as to
how I could "collect" a bunch of stuff that meets the criteria so I
can use .group).

EXAMPLE: I have sixteen shapes on a slide named "TestArea." One is
named "Olive," another "Olboy," and a third named "Ollaly." The other
shapes have names that don't begin with "Ol." This macro applies a red
fill to the three "Ol*" and leaves the others alone.)

Option Explicit
Dim myShapes As Shapes
Dim myShape As Shape

Sub ThisOlTest()
Set myShapes = ActivePresentation.Slides("TestArea").Shapes
For Each myShape In myShapes
If myShape.Name Like "Ol*" Then
With myShape.Fill
.Visible = msoTrue
.Solid
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0#
End With
End If
Next
End Sub

"David M. Marcovitz" wrote:

I could be wrong, but I don't think that PowerPoint can do the Like
thing that you want. You could write more complex If statements,
using such string manipulation functions as Left.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?TGlzYQ==?= <Lisa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:45A49BAA-ECB1-4A97-A603-734B70825067@xxxxxxxxxxxxx:

Essentially, I'm trying to:
�· Check all the shapes on a given slide to determine if they
meet certain criteria (shape's name contains a specific string, or
shape's tag has a specific value)
�· If a shape meets the criteria, add it to an array
�· Use the array to group the shapes or to apply properties
(fill, line, etc) to the shapes in the array

For example, a condensed version of my current code looks something
like this:
myArray = Array("Icon_Hat", "Icon_Tree", "Icon_Star")
With myShapes.Range(myArray).Group
.Name = "myTestEffort"
With .Fill
.Solid
.ForeColor.RGB = RGB(255, 153, 51)
End With
.Line.Visible = msoFalse
End With

Instead of defining the array by listing each shape by name, I'd
like to be able to say something like
If myShape.Name Like "Icon_*" Then ... (put it in myArray)
OR
If myShape.Tags("ImgStyle") = "Icon" Then ... (put it in
myArray)

Unfortunately, I keep getting stuck at the "put it in myArray"
part.

If someone can tell me how to do this -- or refer me to appropriate
documentation, I'd really appreciate it.

Thanks in advance!





.



Relevant Pages

  • Re: How to initialize an array in VBA of named shapes on a slide?
    ... MS PowerPoint MVP Team ... PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com ... There's no problem with declaring an array of shapes. ...
    (microsoft.public.powerpoint)
  • Re: Create array based on shape name or tag
    ... but I don't think that PowerPoint can do the Like thing ... · Check all the shapes on a given slide to determine if they meet ... certain criteria (shape's name contains a specific string, ... · Use the array to group the shapes or to apply properties (fill, ...
    (microsoft.public.powerpoint)
  • Re: Create array based on shape name or tag
    ... into an array so I can group them... ... bunch of stuff that meets the criteria so I can use .group). ... Dim myShapes As Shapes ... Set myShapes = ActivePresentation.Slides.Shapes ...
    (microsoft.public.powerpoint)
  • Re: Text alignment problems in shapes and text boxes
    ... If this occurs only in files generated from the template I'm tempted to ... "shadow" button is off). ... isn't usually an issue because I avoid using PowerPoint for drawing and labels ... and I wanted to use the PowerPoint shapes to maximize ...
    (microsoft.public.mac.office.powerpoint)
  • RE: Determining the ZOrderPosition. What shape is what?
    ... the VBA editor and you will be able to name your shapes. ... Director of Graduate Programs in Educational Technology ... Author of _Powerful PowerPoint for Educators_ ... Case "Rounded Rectangle 3" ...
    (microsoft.public.powerpoint)