Assigning Macro to Shape

bisel

Board Regular
Joined
Jan 4, 2010
Messages
223
Office Version
  1. 365
Platform
  1. Windows
Cannot figure out what is going on and hoping for expert advice.

On my desktop, I have created a workbook with command buttons and graphic shapes and have assigned macros to them. With the command buttons, in the Developer mode I click on "View Code" and assign macros there. No problems.

Also on the desktop, I have inserted several shapes and have assigned macros. I right click on the shape and then click "Assign Macro". No problems.

Now I go over to my laptop and open the same workbook. The command button shapes work fine. But the macros assigned to the shapes do not run. I get error message ... "Cannot run the macro ... name of macro ... the macro may not be available ... " If I go to the macro itself and run it from the VBA editor, it runs fine. But, I cannot run the macro by clicking on the shape on my laptop. Does anyone know of what may be wrong?

Thanks,

Steve
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What modules contains the macros assigned to the shapes? How did you assign the macros to the shapes? Are they declared as Public? Are they in standard modules (like Module1)?

Do you have any way to share your file?
 
Upvote 0
What modules contains the macros assigned to the shapes? How did you assign the macros to the shapes? Are they declared as Public? Are they in standard modules (like Module1)?

Do you have any way to share your file?
Yes. Standard modules and declared as public.
 
Upvote 0
Driving me nuts.

With my existing workbook, which is quite complex, the behavior on the desktop is fine. No issues. Desktop is Win11 with Excel 365. All macros whether assigned to a command button or a shape work as expected.

On my laptop, the very same workbook ... My laptop is Win10 with Excel 365
  • Macros assigned to command buttons work fine.
  • Any macro assigned to a shape results in the message ... "Cannot run the macro ... name of macro ... the macro may not be available ... ". But if I run the macro from the VBA editor, it runs fine.
  • Also, tried to create a new shape and assign a macro to it ... same result.
On my laptop, I then created a new workbook. Created a simple macro and then created a shape. Assigned the macro to the shape. Runs fine. So something going on with existing workbook when I attempt to run it on my laptop.

Took the file over a third PC ... my wife's laptop. Runs fine on her laptop ... no issues at all. Her laptop is Win10 with Excel 2010.

Anyone have any thoughts?

Steve
 
Upvote 0
Hi Steve. I have run into what seems like a similar issue fairly recently. In my case, I have a workbook with code attached to a number of buttons and shapes with associated macros that have all suddenly stopped working.
The workbook is used as a template so there are literally hundreds of copies of it that mysteriously stopped working, all at once about 2 weeks ago.

In my testing, I've found the issue goes away if I enable Excel 4.0 Macros. It's no small coicidence that Microsoft have recently disabled these by default:
To test yourself: Excel Options -> Trust Center -> Macro Settings -> Enable Excel 4.0 Macros when VBA Macros are enabled

This is not a "fix" anybody should use, just curious if you or anybody else with this issue is seeing similar behaviour.

My workbook doesn't contain Excel 4.0 Macros so I believe this is the result of a bug.
 
Upvote 0
Hi Steve. I have run into what seems like a similar issue fairly recently. In my case, I have a workbook with code attached to a number of buttons and shapes with associated macros that have all suddenly stopped working.
The workbook is used as a template so there are literally hundreds of copies of it that mysteriously stopped working, all at once about 2 weeks ago.

In my testing, I've found the issue goes away if I enable Excel 4.0 Macros. It's no small coicidence that Microsoft have recently disabled these by default:
To test yourself: Excel Options -> Trust Center -> Macro Settings -> Enable Excel 4.0 Macros when VBA Macros are enabled

This is not a "fix" anybody should use, just curious if you or anybody else with this issue is seeing similar behaviour.

My workbook doesn't contain Excel 4.0 Macros so I believe this is the result of a bug.
Thanks for the tip.

Interesting that neither my desktop nor laptop had "Enable Excel 4.0 macros" and only the laptop was having problems. I enabled Excel 4.0 macros on the laptop and it is working now. Enable Excel 4 macros is not enabled on the desktop and it is working ok. But, to make sure, I enabled it on the desktop.

I wanted to check on some things and I find that if I toggle enabling Excel 4.0 macros off and on I can recreate the problem ... on both machines. I will leave it turned on as that seems to resolve the issue.

I agree that this seems like a bug.

Steve
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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