Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
Hello Group,
I created a drawing of 3 lines and grouped them. I named the group Maxi I copied and pasted Maxi to a different area. Now there are 2 entities called Maxi When I use Sheet1.Shapes("Maxi").Select. The first original Maxi is selected How do I select the 2nd one ? Thanks, Michael Singmin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
Hi
try dim oshape as shape for each oshape in Sheet1.Shapes if oshape.name="Maxi" then 'do something end if next -- Regards Frank Kabel Frankfurt, Germany "Michael Singmin" schrieb im Newsbeitrag ... Hello Group, I created a drawing of 3 lines and grouped them. I named the group Maxi I copied and pasted Maxi to a different area. Now there are 2 entities called Maxi When I use Sheet1.Shapes("Maxi").Select. The first original Maxi is selected How do I select the 2nd one ? Thanks, Michael Singmin |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
Sheet1.Shapes(1).Select
Sheet1.Shapes(2).Select Why not rename one of them? -- Regards, Tom Ogilvy "Michael Singmin" wrote in message ... Hello Group, I created a drawing of 3 lines and grouped them. I named the group Maxi I copied and pasted Maxi to a different area. Now there are 2 entities called Maxi When I use Sheet1.Shapes("Maxi").Select. The first original Maxi is selected How do I select the 2nd one ? Thanks, Michael Singmin |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
[...]
Why not rename one of them? Hi Tom that solution is probably too simple <vbg nice weekend Frank |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
Did you copy them in code or manually?
If you did it manually, you can rename the copy of the group by selecting it and typing the new name in the name box. If you did it in code, you can use something like: Option Explicit Sub testme() Dim myLine1 As Shape Dim myLine2 As Shape Dim myLine3 As Shape Dim myGroup As Shape Dim myNewShape As Shape With ActiveSheet Set myLine1 = .Shapes.AddLine(271.5, 127.5, 318.75, 186#) Set myLine2 = .Shapes.AddLine(240.75, 135#, 336.75, 180#) Set myLine3 = .Shapes.AddLine(231#, 156#, 372.75, 169.5) Set myGroup = .Shapes.Range(Array(myLine1.Name, _ myLine2.Name, myLine3.Name)).Group myGroup.Name = "maxi" Set myNewShape = myGroup.Duplicate With .Range("a1:c9") myNewShape.Top = .Top myNewShape.Left = .Left myNewShape.Width = .Width myNewShape.Height = .Height End With myNewShape.Name = "maxi2" End With End Sub You can also get the last shape you added with something like: Option Explicit Sub testme() Dim myLine1 As Shape Dim myLine2 As Shape Dim myLine3 As Shape Dim myGroup As Shape Dim myNewShape As Shape With ActiveSheet Set myLine1 = .Shapes.AddLine(271.5, 127.5, 318.75, 186#) Set myLine2 = .Shapes.AddLine(240.75, 135#, 336.75, 180#) Set myLine3 = .Shapes.AddLine(231#, 156#, 372.75, 169.5) Set myGroup = .Shapes.Range(Array(myLine1.Name, _ myLine2.Name, myLine3.Name)).Group myGroup.Name = "maxi" myGroup.Copy .Range("a1:c9").Select .Paste Set myNewShape = .Shapes(.Shapes.Count) myNewShape.Name = "Maxi2" End With End Sub activesheet.shapes.count will be the last shape you added. Michael Singmin wrote: Hello Group, I created a drawing of 3 lines and grouped them. I named the group Maxi I copied and pasted Maxi to a different area. Now there are 2 entities called Maxi When I use Sheet1.Shapes("Maxi").Select. The first original Maxi is selected How do I select the 2nd one ? Thanks, Michael Singmin -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Names of Shapes
Thanks to all the answers.
I was just surprised that Excel allowed 2 entities to have the same name. I learnt a lot from your other answers especially the code below. Much appreciated Michael Singmin ================================================== ============= Dave Peterson wrote: Did you copy them in code or manually? If you did it manually, you can rename the copy of the group by selecting it and typing the new name in the name box. If you did it in code, you can use something like: Option Explicit Sub testme() Dim myLine1 As Shape Dim myLine2 As Shape Dim myLine3 As Shape Dim myGroup As Shape Dim myNewShape As Shape With ActiveSheet Set myLine1 = .Shapes.AddLine(271.5, 127.5, 318.75, 186#) Set myLine2 = .Shapes.AddLine(240.75, 135#, 336.75, 180#) Set myLine3 = .Shapes.AddLine(231#, 156#, 372.75, 169.5) Set myGroup = .Shapes.Range(Array(myLine1.Name, _ myLine2.Name, myLine3.Name)).Group myGroup.Name = "maxi" Set myNewShape = myGroup.Duplicate With .Range("a1:c9") myNewShape.Top = .Top myNewShape.Left = .Left myNewShape.Width = .Width myNewShape.Height = .Height End With myNewShape.Name = "maxi2" End With End Sub You can also get the last shape you added with something like: Option Explicit Sub testme() Dim myLine1 As Shape Dim myLine2 As Shape Dim myLine3 As Shape Dim myGroup As Shape Dim myNewShape As Shape With ActiveSheet Set myLine1 = .Shapes.AddLine(271.5, 127.5, 318.75, 186#) Set myLine2 = .Shapes.AddLine(240.75, 135#, 336.75, 180#) Set myLine3 = .Shapes.AddLine(231#, 156#, 372.75, 169.5) Set myGroup = .Shapes.Range(Array(myLine1.Name, _ myLine2.Name, myLine3.Name)).Group myGroup.Name = "maxi" myGroup.Copy .Range("a1:c9").Select .Paste Set myNewShape = .Shapes(.Shapes.Count) myNewShape.Name = "Maxi2" End With End Sub activesheet.shapes.count will be the last shape you added. Michael Singmin wrote: Hello Group, I created a drawing of 3 lines and grouped them. I named the group Maxi I copied and pasted Maxi to a different area. Now there are 2 entities called Maxi When I use Sheet1.Shapes("Maxi").Select. The first original Maxi is selected How do I select the 2nd one ? Thanks, Michael Singmin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel document with shapes on it but the shapes do not print | Excel Worksheet Functions | |||
Selecting shapes with unknown names | Excel Discussion (Misc queries) | |||
Naming Auto Shapes and Creating new Shapes | Excel Discussion (Misc queries) | |||
When drawing shapes in excel the shapes keep disappearing | Excel Discussion (Misc queries) | |||
How can i get more 3D shapes for Auto shapes in excel? | Excel Discussion (Misc queries) |