Thread: Names of Shapes
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default 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