Clicked shape in EXCEL used as shape object to find its attributes

Prashanth_Pasunuti

New Member
Joined
Jun 24, 2021
Messages
17
Office Version
  1. 2016
Platform
  1. Windows
Hello,

First assign a macro for a shape in EXCEL. When we press the macro how can we make the clicked shape as the object and find its attributes like .top, .left details etc.
What i have done.
'***********************************************
dim shp as shape
set shp = selection

with shp
shape_left = .left
shape_top = .top

end with
'*********************************************
The point is when i click on any shape the macro should run and it should give the corresponding details of that shape.

Please help
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Code:
Set shp = activesheet.shapes(application.caller)

should do the job.
 
Upvote 0
Code:
Set shp = activesheet.shapes(application.caller)

should do the job.
Hello sir. done but it is saying " the item with the specified name wasnt found".

Dim myshape As Shape
Set myshape = ActiveSheet.Shapes(Application.Caller)


With myshape
shape_left = .Left
shape_top = .Top
shape_left_width = .Left + .Width
shape_top_height = .Top + .Height
' shape_name = .name
' shape_rgb = .ForeColor
End With
 
Upvote 0
Is the macro assigned to all the shapes? If so, what is the name of the shape that fails? (this method will only work with shape names up to 31 characters)
 
Upvote 0
Is the macro assigned to all the shapes? If so, what is the name of the shape that fails? (this method will only work with shape names up to 31 characters)
Macro is assigned to specific shapes only. Its like if i click the shape with macro assigned then it should give the details of the shape.
 
Upvote 0
And what is the name of the shape you were clicking?
 
Upvote 0
Add:

Code:
Msgbox Application.Caller

to the start of the code and check if the message matches the shape name
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top