Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a worksheet with various shapes already on it. I add new shapes.
I want to collect the new shapes only and group them. How do I build a selection consisting of the newly created shapes. The number of added shapes is dynamic so I don't know of any way to use Array(...) with Range and the shape indexes. TIA *** Sent via Developersdex http://www.developersdex.com *** |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This adds a variable number of rectangles and selects them:
Sub Macro2() ActiveCell.Select num = Int(Rnd() * 5 + 1) Debug.Print num For i = 1 To num l = Rnd() * ActiveWindow.VisibleRange.Width t = Rnd() * ActiveWindow.VisibleRange.Height Debug.Print t, l ActiveSheet.Shapes.AddShape(msoShapeRectangle, l, t, _ 55.5, 18#).Select False Next End Sub The false argument to select says to add to the currently selected shape(s) -- Regards, Tom Ogilvy "Edward Ulle" wrote in message ... I have a worksheet with various shapes already on it. I add new shapes. I want to collect the new shapes only and group them. How do I build a selection consisting of the newly created shapes. The number of added shapes is dynamic so I don't know of any way to use Array(...) with Range and the shape indexes. TIA *** Sent via Developersdex http://www.developersdex.com *** |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
Thanks. The select method is so far down the chain I couldn't find it. By the way do you ever sleep? Ed *** Sent via Developersdex http://www.developersdex.com *** |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Edward,
I recently had a similar challenge and this is how I was able to do it... When I created the new shapes, I added some identifying characters to each shape name. (.Name = "XXX" & .Name). Then when I wanted to find the shapes, I iterated through all of the shapes in the worksheet. When I found one whose name began with the string that I added, I added that name to an array of variants. It must be an array of Variants, not strings. Then I created a ShapeRange set containing the names that I wanted (Set SR = ActiveSheet.Shapes.Range(ShapeNames()), where ShapeNames() is the array of names) Then you could execute SR.Select to get where you want. In my case I created a Shape Group. I was able to get it to work in this manner. Hope that this helps. Dan Fisher "Edward Ulle" wrote in message ... I have a worksheet with various shapes already on it. I add new shapes. I want to collect the new shapes only and group them. How do I build a selection consisting of the newly created shapes. The number of added shapes is dynamic so I don't know of any way to use Array(...) with Range and the shape indexes. TIA *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel document with shapes on it but the shapes do not print | Excel Worksheet Functions | |||
Naming Auto Shapes and Creating new Shapes | Excel Discussion (Misc queries) | |||
When drawing shapes in excel the shapes keep disappearing | Excel Discussion (Misc queries) | |||
Programmatically add shapes to a selection | Excel Programming | |||
Disable selection of shapes | Excel Programming |