Microsoft Office 2000 Developer   

Code Commenter and Error Handler Template Formats

See Also

The VBA Code Commenter and VBA Error Handler add-ins work by inserting text from a specified template into each procedure in the scope chosen by the user (current procedure, module, or project). You can create your own templates, using Notepad or another text editor, by saving the file with a .eht file extension.

These templates contain replaceable tokens that specify what will be added to your code. As the add-in is inserting text, it searches for these tokens:

Token Meaning
$$A Author. Replaced with the current author name.
$$B Procedure body.
$$D Current date, formatted as Windows short date.
$$H Header comments.
$$I Author initials.
$$N Name of procedure. Replaced with the fully-qualified procedure name, including the class name if it's a member of a class.
$$P Project name.
$$T Current time, formatted as Windows short time.
$$V Header variables.
$$Y Type of procedure. Replaced with "Sub", "Function" or "Property" as appropriate.
$$SA Start Auto. Used to flag the start of an inserted error handler.
$$EA End Auto. Used to flag the end of an inserted error handler.
$$SH Start of header.
$$EH End of header.

The $$B, $$H, and $$V tokens are used to locate the replacement text within the existing procedure. If these are used in the template, they must appear on separate lines, in the order $$H, $$V, $$B.

The $$A and $$I tokens are used to insert the name and initials of the current developer. The add-in first tries to read these from the registry under HKCU/Software/Microsoft/ODE/9.0. You enter the name and initials information in the add-in window. If new values are entered in the Name and Initials fields, the add-in uses those values and stores them in the registry for future use. If the values are not stored in HKCU/Software/Microsoft/ODE/9.0, the add-in then checks the registry to find the default values for the registered user of the product.

When the add-in encounters the $$SH token, it inserts the comment:

' Code Commenter block inserted by Procedure Header Add-in

When the add-in encounters the $$EH token, it inserts the comment:

' End Code Commenter block

If the add-in finds its $$SH token in an existing procedure, it makes no modifications to that procedure.

When the add-in encounters the $$SA token, it inserts the comment:

'  Error Handler block added by VBA Error Handler Add-in. DO NOT _
      edit this block of code.

When the add-in encounters the $$EA token, it inserts the comment:

' End Error Handling block.

If the add-in finds a $$SA token in an existing procedure, it makes no modifications to that procedure unless you have selected the Update existing error handlers option in the VBA Error Handler dialog box. When this option is selected, the Error Handler updates the procedure with the current information.

Important   In order to be recognized as a valid template file, the file must contain at least the following tokens: $$B plus either $$SH and $$EH or $$SA and $$EA. If the required tokens are missing, an error will occur when attempting to load the .eht file.

For more information, see Chapter 11, "Add-ins, Templates, Wizards, and Libraries" in the Microsoft Office 2000/Visual Basic Programmer's Guide.