Click here to Skip to main content
15,389,584 members
Articles / Programming Languages / Visual Basic
Posted 17 Feb 2010

Tagged as


15 bookmarked

VBA Code Tools

Rate me:
Please Sign up or sign in to vote.
3.83/5 (6 votes)
17 Feb 2010CPOL2 min read
Using the VBA Extensibility Library to add comment headers to your code.


You have probably heard about all the benefits of commenting your code. If you are really old school, you may have heard about the POYS (the Programmer Over Your Shoulder), that guy that is you from the past telling you what you were thinking when you wrote that nifty (or awful) code snippet.

Of course, most of the time, we do not have the time to bother commenting our code. That is why a couple of shortcuts might help. If you are enforced by someone else to comment your code, this will take some of the burden out of it.

This set of subs create a comment header and insert a 'Modified' date line into an existing comment header, as shown on the code pane on the right:

Image 1

The subs should work fine across Office 2003-2007/VBA6.5 applications, but it has been tested in Access 2003 and 2007 exclusively. Of course, everything has changed again with Office 2010, but I bet there is a lot of applications out there using true and tried VBA.

Using the Code

To use the code, simply create a reference to the extensibility library (as shown in the next image) and import the codetools.bas file into your project.


To add a comment header to your code, you set the cursor inside a sub or function and type sysaddheader in the debug pane. When you hit Eenter, a comment header is added right above the sub or function (or to the module, if the cursor is not inside a sub or function body).

You can customize the header in any way you want. The default header will include the sub/function (or module) name, the creation date, and the modified date.

Another macro, sysaddmodified, will insert an extra modified date at the bottom of the comment header.

Incidentally, the sys prefix just helps me distinguish code extensibility functions from regular functions.

Points of Interest

Chances are you love reminiscing in your old code or you hate commenting code. Either way, this might save you some of the trouble. For one thing, it is fun to go back to some code pieces that seem to traverse languages and the test of time.


First public release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

hector [.j.] rivas
Software Developer (Senior) Texas Capital Bank
United States United States
Professional software engineer with 30+ years of experience delivering systems across diverse industries, looking for the next opportunity to deliver cutting edge end-to-end technology solutions.

Avid reader, disciplined writer and enthusiastic tinkerer with a background in electronics, looking inside and thinking outside the box, genuinely passionate about robust, extensible, reusable and performant code.

Framework developer leading, coaching and learning about best practices, code quality, DevOps and software and data lifecycle management with an agile mindset to create the most elegant and sustainable solutions.

Comments and Discussions

GeneralThumbs up Pin
Member 103757752-Nov-13 2:34
MemberMember 103757752-Nov-13 2:34 
GeneralProblem Pin
shutao10-May-10 9:58
Membershutao10-May-10 9:58 
GeneralRe: Problem Pin
Muller.Ben5-Jun-10 18:25
MemberMuller.Ben5-Jun-10 18:25 
GeneralRe: Problem Pin
hector [.j.] rivas3-Sep-13 2:09
Memberhector [.j.] rivas3-Sep-13 2:09 
GeneralMy vote of 1 Pin
AxelM21-Feb-10 21:54
MemberAxelM21-Feb-10 21:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.