Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Names of Shapes

[...]

Why not rename one of them?


Hi Tom
that solution is probably too simple <vbg

nice weekend
Frank
  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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
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
excel document with shapes on it but the shapes do not print [email protected] Excel Worksheet Functions 2 October 22nd 09 06:17 PM
Selecting shapes with unknown names JBCI Excel Discussion (Misc queries) 0 March 10th 08 05:45 PM
Naming Auto Shapes and Creating new Shapes AL2000 Excel Discussion (Misc queries) 3 September 10th 07 04:12 AM
When drawing shapes in excel the shapes keep disappearing Tape Excel Discussion (Misc queries) 1 October 6th 06 04:23 PM
How can i get more 3D shapes for Auto shapes in excel? Ajey Excel Discussion (Misc queries) 0 March 3rd 05 09:53 AM


All times are GMT +1. The time now is 07:50 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"