Link to home
Start Free TrialLog in
Avatar of mabehr
mabehr

asked on

"Cannot run the macro ...The macro may not be available in the workbook or all marcros may be disabled."

I get this message when I click on a button to run a macro:
"Cannot run the macro ...The macro may not be available in the workbook or all marcros may be disabled."

I do have my macro settings in the Trust Center as "Enable all macros..." and the "Trust access to the VBA project..." enabled
but when I click on the button that is what I get.
And I do have the file saved as a .xlsm and .xls and neither way works. Any ideas?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Do you have the macro defined as

Private Sub MyMacro

or

Public Sub MyMacro

If so change it to
Sub MyMacro

and move it to a code module (like module1) if it's not already there. You may have to insert a module if you don't have module1.
It is very likely that the macro has been renamed.

Right-click on the button object (if a Form control object) then select "Assign Macro..." and ensure that it is referring to the correct macro.   The alternate solution is to rename your macro back to the name the button was referring to.

Regards,
-Glenn
Avatar of mabehr
mabehr

ASKER

Thanks Glenn. It is pointing to the right macro (there's only one) but maybe my button is not really a button. I just drew a rectangular object and assigned the macro to it. Should that work?
Avatar of mabehr

ASKER

@MartinLiss, I'll post a screen shot of what everything looks like tomorrow when I get to work. Thanks.
Yes your shape should work but I bet your macro didn't show up in the list.
Martin is correct; a drawing object should work.  However, check carefully the name of the macro seen using the "Assign Macro..." steps I listed above with the name (and possibly path) of the macro in your workbook.
Avatar of mabehr

ASKER

Attached are screenshots showing my setttings and code but still getting the error.
Screen-Shot-07-15-14-at-08.19-AM.PNG
Screen-Shot-07-15-14-at-08.20-AM.PNG
Screen-Shot-07-15-14-at-08.20-AM-001.PNG
ASKER CERTIFIED SOLUTION
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mabehr

ASKER

Ahhh!!! Screenshots always help in discovering the problem. In this case user error. Thanks Glenn Ray. That worked and it now does what it's supposed to do. Thank you VERY much!