使用按钮运行 Excel 宏不起作用 [英] Running Excel macro using button not working

查看:218
本文介绍了使用按钮运行 Excel 宏不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电子表格上的宏已经运行多年,不再通过按钮运行,尽管它们在 VBA 开发人员窗口中仍然可以正常工作.我使用普通形状(矩形)作为按钮并为其分配宏(从ThisWorkbook"中选择).

Macros on my spreadsheet that have been working for years, stopped working via buttons, though they still work fine from VBA Developer window. I use a normal shape (rectangle) as the button and assigned the Macro to it (selecting from "ThisWorkbook").

为了阻止我在其他类似帖子中看到的建议修复...

To head off suggested fixes I've seen for other similar posts...

  • 它仍然是一个 .xlsm 文件
  • 宏仍处于启用状态.
  • 它和以前一样在同一台笔记本电脑上运行(Windows 10、Office 365).
  • 最近没有进行 Windows 更新.
  • 我只打开了这个文件.
  • 我尝试重新启动笔记本电脑并重新启动 Excel.
  • 我没有使用 Active-X 控件.
  • 我尝试使用表单控件按钮和常规形状按钮 - 两者都不起作用.
  • 它与实际的 VBA 代码无关(请参阅下面的证明).

我创建了一个新程序来显示问题不是代码本身:

I created a new program to show the problem is not the code itself:

Sub button_not_working()
    MsgBox "button_not_working"
End Sub

此程序使用 VBA 屏幕中的绿色播放"按钮运行,但不通过工作表上指定的按钮运行.任何想法将不胜感激!------------ 更多信息 -------------代码位于普通的 VBA 代码模块中(不是 VBA 屏幕上的ThisWorkbook"区域).宏是通过右键单击形状分配的,可用宏的列表就是本工作簿"中的那些.在分配宏"弹出窗口中.截图如下...单击形状以运行指定的宏时,我收到此错误消息...

This program works using the green Play button in the VBA screen, but not via an assigned button on a sheet. Any idea would be greatly appreciated! ------------ Further Info ------------- Code is in a normal VBA code Module (not "ThisWorkbook" area on VBA screen). Macro is assigned by right-clicking shape, and the list of available Macros is just those in "This Workbook" on the Assign Macro popup. Screenshot below... When clicking the Shape to run the assigned macro I get this error message...

推荐答案

已解决 - 结果我需要选中启用 Excel 4.0 宏"框.显然,微软从本月开始在 Office 365 中默认禁用此功能!

Solved - turned out I needed to check the box for "Enable Excel 4.0 Macros". Apparently, Microsoft has just started disabling this by default in Office 365 starting this month!

所以在 Excel 中...文件>>选项>>信任中心>>信任中心设置>>宏设置

So in Excel... File>>Options>>Trust Center>>Trust Center Settings>>Macro settings

这篇关于使用按钮运行 Excel 宏不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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