How to comment and uncomment blocks of code in the Office VBA Editor

后端 未结 9 799
醉酒成梦
醉酒成梦 2020-12-02 04:21

In the VBA editor of Office (ALT + F11), how do you comment or uncomment a block of code?

9条回答
  •  情深已故
    2020-12-02 04:52

    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.
      Press Enter to save the change.
    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. Voila.
    10. Do the same thing for the Uncomment Block or
      any other commands that you find yourself using often.

提交回复
热议问题