Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Select Multiple Shape Objects

Thanks for the quick response.

After a few experiments it works.

I removed "As String" from my array declaration.

I removed my "Redim" statements before and after the loop and replaced them
with a single "Redim" statement inside the loop.

I'm a little confused why this was causing a problem.

Thanks for the help.



"Doug Glancy" wrote:

Alan,

This works for me:

Sub test()

Dim shapeobject As Shape
Dim i As Long
Dim ShapeObjectNameArray()

i = 0
For Each shapeobject In Worksheets(1).Shapes
If Left(shapeobject.Name, 6) = "MyName" Then
ReDim Preserve ShapeObjectNameArray(i)
ShapeObjectNameArray(i) = shapeobject.Name
i = i + 1
End If
Next shapeobject
Worksheets(1).Shapes.Range(ShapeObjectNameArray).S elect

End Sub

hth,

Doug Glancy
"Alan" wrote in message
...
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).Se lect

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(ShapeObjectNameArr ay(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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I select and delete multiple objects from a worksheet? Stewart Excel Discussion (Misc queries) 3 March 6th 09 08:26 AM
How can I rotate objects in draw without changing shape? oldgunnersmate New Users to Excel 1 October 17th 08 07:21 PM
How does one select multiple drawn objects in Excel 2007? JakeA Excel Discussion (Misc queries) 1 March 8th 08 03:58 PM
how can I select multiple drawing objects at once ExcelUser Excel Discussion (Misc queries) 1 February 11th 05 10:42 AM
Run-Time Error: You must select a shape Lee Excel Worksheet Functions 1 January 25th 05 05:31 PM


All times are GMT +1. The time now is 06:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"