Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Comment multiple lines (XP)

    Is there a simple way or an add in that easily enables commenting multiple lines of VBA code?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Comment multiple lines (XP)

    Do you want to make multiple lines into a comment by inserting an apostrophe before them (or reversing this)? The Edit toolbar in the Visual Basic Editor has "Comment Block" and "Uncomment Block" buttons.
    Or do you want to create a comment that applies to multiple lines?

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    Thanks Hans, that is exactly what I needed.

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comment multiple lines (XP)

    One of the chores with every Office installation is to add right-click functionality for Comment and UnComment in the VBEditor. It is interesting that there has been neither market research nor significant user pressure on Microsoft to incorporate this by default.
    Gre

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    I know developers who haven't discovered Comment Block and Uncomment Block yet because it isn't in their faces. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Comment multiple lines (XP)

    The first thing I do when using VB Editor for first time on a new installation (a too-frequent occasion) is to customize VBE "Standard" toolbar to include the Comment Block & Uncomment Block commands, as well as Indent & Outdent, Debug Window, References, etc that aren't there by default. When commenting code it is also useful to note that the line continuation character (space plus underscore) also continues comment on next line w/o need to add the apostrophe at start of line.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Comment multiple lines (XP)

    That is exactly what I do too - you'd think that programmers at Microsoft would have the same needs <img src=/S/nope.gif border=0 alt=nope width=15 height=15>

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    I actually prefer them on the context menu, but I usually put them in both places, since the context menu isn't available when the code is executing.
    Charlotte

  9. #9
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    Sorry to sound dumb, but how do you access the right click menu in VBA to add to it?
    Thanks

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Comment multiple lines (XP)

    Select Tools | Customize... (in the Visual Basic Editor)
    Activate the Toolbars tab.
    Tick Context Menus.
    A temporary toolbar will appear with menus and submenus representing the various right-click menus. You want to modify the Program Code Window menu.

  11. #11
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    Thanks everyone for all these enlightening comments. Hope someone "up there" is listening.

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    Actually I am in Access VBA, there is no customize by tools, only View-Toolbars-Customize-Shortcut Menus. A small form pops up with arrows to different context menus, but how do I customize them?
    Thanks

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Comment multiple lines (XP)

    The "small form" is the temporary toolbar I meant in my previous reply.
    Click on the Code Window menu in this toolbar.
    Click on the Code Window submenu.
    You'll see the context menu.
    Activate the Commands tab of the Customize window.
    Select Edit in the Categories list.
    Locate Comment Block in the commands list and drag it to the context menu.
    Repeat for Uncomment Block.

    Note: the caption "Code Window" may be slightly different, I am using a non-English version at the moment.

  14. #14
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Comment multiple lines (XP)

    Thanks. Now I got it

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comment multiple lines (XP)

    Select the lines and hit the toolbar icon that converts them to comments.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •