如何编辑 Excel 2011 VBA 按钮而不是单击它们

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16104433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:43:41  来源:igfitidea点击:

How to edit Excel 2011 VBA buttons instead of clicking them

excelexcel-vbaexcel-vba-macvba

提问by egor7

When I click the VBA buttons in Excel 2007 I go to edit mode. But when I'm trying to modify them inExcel 2011 - I click it, and it clicks! But how to switch command mode and edit mode?

当我在 Excel 2007 中单击 VBA 按钮时,我会进入编辑模式。但是当我尝试在 Excel 2011 中修改它们时 - 我点击它,它点击了!但是如何切换命令模式和编辑模式呢?

回答by Siddharth Rout

Excel 2011 doesn't support ActiveX Controls. It only supports Form Controls. And to access the code area you may follow any of the following steps

Excel 2011 不支持 ActiveX 控件。它只支持表单控件。要访问代码区域,您可以按照以下任何步骤操作

  1. Right Click on the form button, then on Assign Macro. In the next dialog box, Click on New

  2. Press fn+ALT+F11to access the VBA Editor. Create a sub in a module and then link it to the form button using Assign Macroas mentioned above

  3. Click on the Excel Menu next to the Apple Icon, and then click on Preferences. Click on Ribbonin Sharing and Privacyand then select the Developer checkbox.

  1. 右键单击表单按钮,然后单击Assign Macro。在下一个对话框中,单击New

  2. fn+ ALT+F11访问 VBA 编辑器。在模块中创建一个子项,然后使用Assign Macro上述方法将其链接到表单按钮

  3. 单击 Apple 图标旁边的 Excel 菜单,然后单击首选项。单击“Ribbon进入” Sharing and Privacy,然后选择“开发人员”复选框。

ScreenShot:

截图

enter image description here

在此处输入图片说明

回答by lostlain

You need to first make sure you have the developer tools added to the ribbon: Select File, Options, then select Customize Ribbon and make sure the "Developer" tab is selected. Click Ok. Then you can go to the Developer ribbon tab and select "Design Mode" This will let you edit things and will change the button behaviour so that double clicking will open associated code.

您需要首先确保已将开发人员工具添加到功能区:选择“文件”、“选项”,然后选择“自定义功能区”并确保选择了“开发人员”选项卡。单击确定。然后您可以转到“开发人员”功能区选项卡并选择“设计模式”这将允许您编辑内容并更改按钮行为,以便双击将打开相关代码。