在Office的VBA编辑器(ALT + F11)中,如何注释或取消注释代码块?
当前回答
Right-click on the toolbar and select Customize... Select the Commands tab. Under Categories click on Edit, then select Comment Block in the Commands listbox. Drag the Comment Block entry onto the Menu Bar (yep! the menu bar) Note: You should now see a new icon on the menu bar. Make sure that the new icon is highlighted (it will have a black square around it) then click Modify Selection button on the Customize dialog box. An interesting menu will popup. Under name, add an ampersand (&) to the beginning of the entry. So now instead of "Comment Block" it should read &Comment Block. Press Enter to save the change. Click on Modify Selection again and select Image and Text. Dismiss the Customize dialog box. Highlight any block of code and press Alt-C. Voila. Do the same thing for the Uncomment Block or any other commands that you find yourself using often.
其他回答
或者只是点击查看,工具栏,编辑。然后,您可以选择一段代码,然后单击“注释”或“取消注释”工具栏按钮,一键完成所有操作。
另外,你也可以用Tab/Shift+Tab键对选定的文本块进行标记。当我还是个新手的时候,我很长一段时间都不知道,每次都是一行一行地做。
好运!
在VBA编辑器中,选择“查看”、“工具栏”、“自定义”…或者右键单击工具栏并选择自定义…
在Commands选项卡下,选择左边的Edit菜单。
然后大约三分之二的地方有两个图标,注释块和取消注释块。
将这些拖放到工具栏上,然后您就可以轻松地高亮显示代码块,并通过单击按钮注释或取消注释!
如果你想分配键盘快捷键,请参阅GauravSingh的答案。
安装了MZ-Tools后,我使用快捷键在VBE中注释/取消注释块 Ctrl+Alt+C (MZ-Tools默认)
你查过MZTools了吗??它能做很多很酷的事情…
如果我没说错的话,它提供的功能之一是设置你自己的快捷方式。
Right-click on the toolbar and select Customize... Select the Commands tab. Under Categories click on Edit, then select Comment Block in the Commands listbox. Drag the Comment Block entry onto the Menu Bar (yep! the menu bar) Note: You should now see a new icon on the menu bar. Make sure that the new icon is highlighted (it will have a black square around it) then click Modify Selection button on the Customize dialog box. An interesting menu will popup. Under name, add an ampersand (&) to the beginning of the entry. So now instead of "Comment Block" it should read &Comment Block. Press Enter to save the change. Click on Modify Selection again and select Image and Text. Dismiss the Customize dialog box. Highlight any block of code and press Alt-C. Voila. Do the same thing for the Uncomment Block or any other commands that you find yourself using often.
推荐文章
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- Swift:理解// MARK
- 在构建中编写注释的语法是什么?gradle文件?
- Java注释中的/**和/*
- Visual Basic 6.0与VBA的区别
- 有没有办法注释掉.ASPX页面中的标记?
- .text, .value和.value2之间的区别是什么?
- Jenkins:注释可以添加到Jenkins文件中吗?
- TypeScript注释的语法记录在哪里?
- CSV文件可以有注释吗?
- 检查一个字符串是否包含另一个字符串
- 什么是自文档化代码?它能取代文档化良好的代码吗?
- 循环通过文件夹中的文件使用VBA?
- 在erb中添加注释的最佳方法
- 为什么Python没有多行注释?