'Cannot run the macro. "The macro may not be available or all macros may be disabled"
This topic has been already mentioned, however without a solution. I have a very simple Macro calling other workbooks and their macros to execute:
Sub Execute()
Workbooks.Open Filename:="C:Beta.xlsm"
Application.Run "C:Beta.xlsm!Macro"
Workbooks.Open Filename:="C:Alpha.xlsm"
Application.Run "C:Alpha.xlsm!Macro1"
ThisWorkbook.SaveChanges = False
Application.Quit
End Sub
The problem is that, now I receive an error 1004
with a message: Cannot run the macro The macro may not be available or all macros may be disabled.
PS. I have already enabled Macros and ticked the box in Trust Centre (still having error).
Solution 1:[1]
I have reinstalled the entire MS Office package. Now it works. I have no idea what caused this issue. There was no other solution to it. I have applied everything that has been mentioned in this and other posts. Thanks for ur time tho.
Solution 2:[2]
on the ribbon click DEVELOPER --> Macro Security (yellow triangle with exclamation mark)--> Macro Setting --> Enable all macros.
Solution 3:[3]
Make sure you specify the full path to the .xlsm files (here in C:\temp) otherwise current directory is used.
To run the macro, remove the path (only xlsm file name)
Sub Execute()
Workbooks.Open Filename:="C:\Temp\Beta.xlsm"
Application.Run "Beta.xlsm!Macro"
Workbooks.Open Filename:="C:\Temp\Alpha.xlsm"
Application.Run "Alpha.xlsm!Macro1"
ThisWorkbook.SaveChanges = False
Application.Quit
End Sub
Solution 4:[4]
Be sure that module name and sub name are not the same. In other words module name must have a different name respect the sub name.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | West |
Solution 2 | MarcinSzaleniec |
Solution 3 | SBF |
Solution 4 | Naccio |