问题
Macros created and updated to .dotm files work well on the creator's PC, but when distributed to other users they do not work (run).
Tried and double-checked the Trust center settings on MS Word: Macro setting is 'Enable all macros'. Ensured that the location the ("%appdata%\Microsoft\Word\Startup") is already a Trusted Location.
Ensured that all the check points mentioned in this link are as expected.
The code is created following this tutorial:
While the VBA add-in gets recognized, when I click on the add-in button the macro does not run. I suspected that the macro code was getting deleted, since I distributed the .dotm files over email. So, I password protected and zipped them, still the same error.
The error message I am getting is the following:
The macro cannot be found or has been disabled because of your Macro Security settings
I would like to be able to run the macro on other PCs as well.
Update I noticed that the macros, I created were not listed in my PC as well. Now, additionally I did the following change.
Public Sub export_main()
Call export_helper
End Sub
where,
Public Sub export_helper (ByVal control As IRibbonControl)
'do stuff
End Sub
With this the macro was getting listed in other PC as well. Since, I did not pass the control value expected for the function export_helper
from export_main
, the macro threw an error, saying arguments are not supplied. How do I fix this without getting the argument in export_main
. Since VBA seems to be expecting a function with no arguments to be listed in the macros window (am not sure if this is right.)
来源:https://stackoverflow.com/questions/56188333/unable-to-run-macros-in-dotm-files-on-other-pcs