无法运行宏...该工作簿中的宏可能不可用 [英] Cannot run the macro... the macro may not be available in this workbook

查看:3290
本文介绍了无法运行宏...该工作簿中的宏可能不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在不同的工作表上调用一个子文件,但是我有一个运行时错误消息。

I am trying to call a sub on a different worksheet but I got a run time error message.

具体来说,我在这些工作表中有两个工作表和多个VBA子。在VBA项目之一(说workbook1.xlsm)中,我有以下代码:

Specifically, I have two worksheets and multiple VBA sub s in those worksheets. In one of the VBA Project (say workbook1.xlsm), I have the following code:

Sub AnalysisTableMacro()
Workbooks("Python solution macro.xlsm").Activate
Application.Run "Python solution macro.xlsm!.PreparetheTables"
End Sub

但是我收到以下错误。两个工作表上的宏都被启用。在两个工作表中,子模块都在Module1中。

But I got the following error. The macros on both worksheets are enabled. In both worksheets, the subs are in Module1.


无法运行宏Workbook.xlsm!PrepareTheTables。这个工作簿中的宏可能不可用,或者所有宏都可能被禁用。

Cannot run the macro 'Workbook.xlsm!PrepareTheTables'. The macro may not be available in >this workbook or all macros may be disabled.

我还尝试过应用程序.RunPython解决方案macro.xlsm!Module1.PreparetheTables但没有工作。

I also tried Application.Run "Python solution macro.xlsm!Module1.PreparetheTables" but did not work.

任何帮助将不胜感激。

推荐答案

Per Microsoft的KB ,尝试允许对Visual Basic项目进行编程访问:

Per Microsoft's KB, try allowing programmatic access to the Visual Basic project:



  1. 点击Microsoft Office按钮,然后单击Excel选项。

  2. 单击信任中心。

  3. 单击信任中心设置。

  4. 单击宏设置。

  5. 单击以选中对VBA项目对象模型的信任访问复选框。

  6. 单击确定关闭Excel选项对话框

  7. 您可能需要关闭并重新打开excel。

  1. Click the Microsoft Office Button, and then click Excel Options.
  2. Click Trust Center.
  3. Click Trust Center Settings.
  4. Click Macro Settings.
  5. Click to select the Trust access to the VBA project object model check box.
  6. Click OK to close the Excel Options dialog box.
  7. You may need to close and re-open excel.


这篇关于无法运行宏...该工作簿中的宏可能不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆