fyr91
fyr91

Reputation: 1293

How to identify the clicked shape name in VBA

I am trying to create an excel template where I have already assigned different macros to different shape that act as buttons. Now I am having problem of locating which one I have clicked since I need to modify the attributes of the clicked shape after clicking on that shape. While searching on this problem, I have noticed that there is a way to identify which shape has been selected whereas I still doesn't know How to get the name of the shape I have clicked or is there a way to refer to that clicked shape in VBA? Thank you!

Upvotes: 9

Views: 68555

Answers (3)

Sancarn
Sancarn

Reputation: 2824

This suffices:

Msgbox Application.Caller

Upvotes: 0

Sam
Sam

Reputation: 7303

You should be able to get the name of the clicked shape by using Application.Caller

usage as shown

 CallingShapeName = ActiveSheet.Shapes(Application.Caller).Name 

 msgbox CallingShapeName

Upvotes: 20

user12573120
user12573120

Reputation: 21

ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text

Upvotes: 2

Related Questions