G
Guest
How do I select multiple Shape Objects?
I have many shape objects on a worksheet and would like to select a subset
of them based on their name, ie select all Shape Objects whose name begins
with "MyName". I can then group and move them in single operation.
I have the following:
Dim ShapeObjectNameArray() as string
i = 0
for each shapeobject in Worksheet(1).Shapes
if Left(shapeobject.Name, 6) = "MyName" then
ShapeObjectNameArray(i) = shapeobject.Name
i = i + 1
end if
next shapeobject
Redim Preserve ShapeObjectNameArray(i)
Worksheet(1).Shapes.Range(ShapeObjectNameArray).Select
There is a runtime error stating a parameter has an invalid value. Appears
the Range(ShapeObjectNameArray) is unacceptable. The following works but
does not select all the desired shapes:
Worksheet(1).Shapes.Range(Array(ShapeObjectNameArray(1),
ShapeObjectNameArray(2))).Select
I've tried creating arrays and collections of the desired shape object names
and shape objects, then use these as an argument for "Range". They all fail.
Any suggestions?
As a less desirable alternative, I'm willing to select each shape object
individually as i loop thru the shapes. Is there a way to select one object,
then another, then another, etc? Every time I Select an object, the previous
selection is lost. I haven't found an "AddToSelection" or similar method.
thanks.
I have many shape objects on a worksheet and would like to select a subset
of them based on their name, ie select all Shape Objects whose name begins
with "MyName". I can then group and move them in single operation.
I have the following:
Dim ShapeObjectNameArray() as string
i = 0
for each shapeobject in Worksheet(1).Shapes
if Left(shapeobject.Name, 6) = "MyName" then
ShapeObjectNameArray(i) = shapeobject.Name
i = i + 1
end if
next shapeobject
Redim Preserve ShapeObjectNameArray(i)
Worksheet(1).Shapes.Range(ShapeObjectNameArray).Select
There is a runtime error stating a parameter has an invalid value. Appears
the Range(ShapeObjectNameArray) is unacceptable. The following works but
does not select all the desired shapes:
Worksheet(1).Shapes.Range(Array(ShapeObjectNameArray(1),
ShapeObjectNameArray(2))).Select
I've tried creating arrays and collections of the desired shape object names
and shape objects, then use these as an argument for "Range". They all fail.
Any suggestions?
As a less desirable alternative, I'm willing to select each shape object
individually as i loop thru the shapes. Is there a way to select one object,
then another, then another, etc? Every time I Select an object, the previous
selection is lost. I haven't found an "AddToSelection" or similar method.
thanks.