Microsoft Office 2000 Developer   

Automating Code Commenting

See Also

It’s a good practice to add thorough comments to any code that you write. Although it may be perfectly clear to you how your code works, it may not be clear to someone else (or even to yourself) when that code needs to be modified a year from now. Clear comments can save you a lot of time and effort in the future.

The VBA Code Commenter add-in helps you to add consistent comments to your code, including author name, date and time of creation, and other pertinent information. It inserts a header template at the beginning of a procedure; you simply fill in the blanks. You can choose to add comments to a single procedure, to all of the procedures within a module, or to all procedures in your project at once.

To add comments to your code

  1. From the Add-Ins menu, select VBA Code Commenter.

    Note   The VBA Code Commenter menu item is only available when the VBA Code Commenter add-in is loaded. For more information about loading add-ins, see Accessing Office 2000 Developer Tools.

  2. Make a selection from the Add Comments To group to determine whether comments will be added to the current procedure, all procedures in the current module, or all procedures in the current project.

  3. Verify that the desired template is selected in the Code Header Template box.

  4. Type the name and initials for the Author if desired. With the default template, this information appears as part of the code comments. This information is stored in the registry for future use. If you do not enter information, the name and initials default to the registered user of the product.

  5. Click OK.

The VBA Code Commenter uses template files (.eht) to control the format of comments. You can edit the standard template (CodeCommenter.eht) or create your own templates using Notepad or another text editor.

For more information about the templates, see Code Commenter and Error Handler Template Formats and Chapter 11, "Add-ins, Templates, Wizards, and Libraries" in the Microsoft Office 2000/Visual Basic Programmer's Guide.