我试图在不同的工作表上调用子程序,但收到运行时错误消息。
具体来说,我有两个工作表和这些工作表中的多个 VBA sub 。在其中一个 VBA 项目(例如 workbook1.xlsm)中,我有以下代码:
Sub AnalysisTableMacro()
Workbooks("Python solution macro.xlsm").Activate
Application.Run "Python solution macro.xlsm!.PreparetheTables"
End Sub
但是我收到以下错误。两个工作表上的宏均已启用。在两个工作表中,子模块都位于 Module1 中。
Cannot run the macro 'Workbook.xlsm!PrepareTheTables'. The macro may not be available in >this workbook or all macros may be disabled.
我还尝试了Application.Run“Python解决方案macro.xlsm!Module1.PreparetheTables”
但没有工作。
最佳答案
如果工作簿名称中有空格,则必须在文件名两边使用单引号 (')。我还删除了句号。
Application.Run "'Python solution macro.xlsm'!PreparetheTables"
关于excel - 无法运行宏...该宏在此工作簿中可能不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18389562/