如何在Office VBA编辑器中注释和取消注释代码块

本文翻译自:How to comment and uncomment blocks of code in the Office VBA Editor

在Office的VBA编辑器( ALT + F11 )中,如何注释或取消注释代码块?


#1楼

参考:https://stackoom.com/question/Sgxh/如何在Office-VBA编辑器中注释和取消注释代码块


#2楼

In the VBA editor, go to View , Toolbars , Customise... or right click on the tool bar and select Customise... 在VBA编辑器中,转到“ View ,“ Toolbars ,“ Customise...或右键单击工具栏,然后选择“ Customise...

Under the Commands tab, select the Edit menu on the left. 在“ Commands选项卡下,选择左侧的“ Edit菜单。

Then approximately two thirds of the way down there's two icons, Comment Block and Uncomment Block . 然后大约在三分之二的位置有两个图标, Comment BlockUncomment Block

Drag and drop these onto your toolbar and then you have easy access to highlight a block of code, and comment it out and uncomment with the click of a button! 将它们拖放到工具栏上,然后您可以轻松访问以突出显示代码块,并单击一下即可注释掉并取消注释!


See GauravSingh's answer if you want to assign keyboard shortcuts. 如果要分配键盘快捷键,请参阅GauravSingh的答案


#3楼

Have you checked MZTools? 您检查过MZTools吗? ? It does a lot of cool stuff... 它做很多很棒的事情...

If I'm not wrong, one of the functionalities it offers is to set your own shortcuts. 如果我没看错,它提供的功能之一就是设置自己的快捷方式。


#4楼

  1. Right-click on the toolbar and select Customize... 右键单击工具栏,然后选择“ 自定义...”。
  2. Select the Commands tab. 选择命令选项卡。
  3. Under Categories click on Edit , then select Comment Block in the Commands listbox. 类别下,单击编辑 ,然后在命令列表框中选择注释块
  4. 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. 注意:您现在应该在菜单栏上看到一个新图标。
  5. 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. 单击“ 自定义”对话框上的“ 修改选择”按钮。
  6. 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 . 因此,现在应改为“ &Comment Block ”,而不是““ Comment Block””。
    Press Enter to save the change. Enter保存更改。
  7. Click on Modify Selection again and select Image and Text . 再次单击“ 修改选择” ,然后选择“ 图像和文本”
  8. Dismiss the Customize dialog box. 退出“ 自定义”对话框。
  9. Highlight any block of code and press Alt - C . 突出显示任何代码块,然后按Alt - C Voila.
  10. Do the same thing for the Uncomment Block or 对取消注释块执行相同的操作,或者
    any other commands that you find yourself using often. 您经常使用的其他任何命令。

#5楼

An easy way to add buttons to Comment or Un-Comment a code block is: 将按钮添加到CommentUn-Comment代码块的简单方法是:

  • Go to View-Toolbars-Customise 转到查看工具栏自定义
  • Select the Command tab 选择命令选项卡
  • Select the Edit Category on the left 选择左侧的编辑类别
  • Drag the “Comment Block” and “Uncomment Block” icons onto your toolbar. 将“注释块”和“取消注释块”图标拖到工具栏上。

#6楼

There is a built-in Edit toolbar in the VBA editor that has the Comment Block and Uncomment Block buttons by default, and other useful tools. VBA编辑器中有一个内置的“ 编辑”工具栏,默认情况下具有“ 注释块”和“ 取消注释块”按钮,以及其他有用的工具。

If you right-click any toolbar or menu (or go to the View menu > Toolbars ), you will see a list of available toolbars (above the "Customize..." option). 如果右键单击任何工具栏或菜单 (或转到“ 查看”菜单>“工具栏” ),您将看到可用工具栏的列表(“自定义...”选项上方)。 The Standard toolbar is selected by default. 默认情况下,“标准”工具栏处于选中状态。 Select the Edit toolbar and the new toolbar will appear, with the Comment Block buttons in the middle. 选择“ 编辑”工具栏,将出现新的工具栏,中间有“注释栏”按钮。

在此处输入图片说明

*This is a simpler option to the ones mentioned. *这是上述选项中比较简单的选项。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值