ShapeRange.Name

  • Thread starter Thread starter mino
  • Start date Start date
M

mino

Dear All,

1) where can I get the name of a shape put in sheet? I usually create a
macro, select it, and I find the name in the vba code.
2) is possible to assign a specify name to a shape?

Thanks to anyone
M.
 
Put some AutoShapes in a sheet and:

Sub qwerty()
MsgBox (ActiveSheet.Shapes.Count)
i = 0
For Each s In ActiveSheet.Shapes
MsgBox (s.Name)
s.Name = "mino" & i
i = i + 1
Next
End Sub

will tell:

1. you how many are there
2. their names
3. then re-name them
 
The last inserted shape will be the 'topmost' (assuming you haven't changed
order).

Dim shp as Shape
Set shp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count) ' fails if no shapes
shp.Name = "newUniqueName"

See 'AddShape' in help and work with 'shp'
Set shp = ActiveSheet.Shapes.AddShape(arg's...
shp.name =

Regards,
Peter T
 
Many Thanks to you and Gary"s

Peter T said:
The last inserted shape will be the 'topmost' (assuming you haven't
changed order).

Dim shp as Shape
Set shp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count) ' fails if no
shapes
shp.Name = "newUniqueName"

See 'AddShape' in help and work with 'shp'
Set shp = ActiveSheet.Shapes.AddShape(arg's...
shp.name =

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top