Shape names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating several shapes with the code shown below. It works fine.

The problem is that I do not know how to retrieve the shape's name (in the macro) when one shape is selected. Any ideas?

The following is part of the code that creates the shapes.

"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, MyLeft, MyTop, _
MyHoursToGo * MyScale, MyHeight).Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(204, 255, 255)
Selection.ShapeRange.Name = MyName
' Selection.OnAction = "Describe"
Selection.Characters.Text = MyJob & Chr(10) & MyPart & Chr(10) & MyOperation
With Selection.Characters.Font
.Name = "Arial"
.Size = MyFontSize
End With
"

Note that the "OnAction" is commented out because I cannot retrieve the individuals shape's name. Your help is appreciated.

Thank you.
Don
 
Don,

Not really sure what the problem is.

You don't need the n ame to set the OnAction, it works fine without it.

Do you not know the shape name? It is in MyName.

In the macro, you can get the shape name with

Application.Caller

Does any of this help?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Don Rouse said:
I am creating several shapes with the code shown below. It works fine.

The problem is that I do not know how to retrieve the shape's name (in the
macro) when one shape is selected. Any ideas?
The following is part of the code that creates the shapes.

"
ActiveSheet.Shapes.AddShape(msoShapeRectangle, MyLeft, MyTop, _
MyHoursToGo * MyScale, MyHeight).Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(204, 255, 255)
Selection.ShapeRange.Name = MyName
' Selection.OnAction = "Describe"
Selection.Characters.Text = MyJob & Chr(10) & MyPart & Chr(10) & MyOperation
With Selection.Characters.Font
.Name = "Arial"
.Size = MyFontSize
End With
"

Note that the "OnAction" is commented out because I cannot retrieve the
individuals shape's name. Your help is appreciated.
 

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