Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I select and delete multiple objects from a worksheet? | Excel Discussion (Misc queries) | |||
How can I rotate objects in draw without changing shape? | New Users to Excel | |||
How does one select multiple drawn objects in Excel 2007? | Excel Discussion (Misc queries) | |||
how can I select multiple drawing objects at once | Excel Discussion (Misc queries) | |||
Run-Time Error: You must select a shape | Excel Worksheet Functions |