WithEvents for a Shape

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,834
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am trying to find an event for a shape but this does not work:


Code:
Public WithEvents ShapesEvent As Shapes


because VBA doesn't recognise Shapes.


What should I declare it as?


Thanks
 
Last edited:
@ Jaafar

Well Done !!!

It looks like removing the hook is not working as expected ( Windows XP - Excel 2007)

Thanks for testing the code James.

Did you download the workbook demo ?

What happens when you click on the 'Remove Right-Click Macro...' button ? The shapes have a OnAction macro attached to them as well (Left Click)... Are you sure it is not the Left Click Macro (OnAction Macro) that runs instead of the Right-Click macro ?
 
Last edited:
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Thanks for testing the code James.

Did you download the workbook demo ?

What happens when you click on the 'Remove Right-Click Macro...' button ? The shapes have a OnAction macro attached to them as well (Left Click)... Are you sure it is not the Left Click Macro (OnAction Macro) that runs instead of the Right-Click macro ?

Yes ... downloaded the demo ...

Yes ... using the right-click on the 'Remove' commandbutton ... and nothing happens ... since all shapes still have the right click operational ...

Hope this clarifies
 
Upvote 0
Yes ... downloaded the demo ...

Yes ... using the right-click on the 'Remove' commandbutton ... and nothing happens ... since all shapes still have the right click operational ...

Hope this clarifies

No... Only the shapes that are inside the frame will have the right-click operational.

If you want to add the right-click functionality to ALL shapes then they will have to be added in the code one by one.
 
Upvote 0
Jaafar

Obviously ... am talking ONLY about the 3 shapes ... inside the frame ... :wink:
 
Upvote 0

Forum statistics

Threads
1,215,720
Messages
6,126,439
Members
449,314
Latest member
MrSabo83

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