Click here to Skip to main content
Licence CPOL
First Posted 17 Feb 2010
Views 9,512
Downloads 142
Bookmarked 10 times

VBA Code Tools

By | 17 Feb 2010 | Article
Using the VBA Extensibility Library to add comment headers to your code.

Introduction

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:

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.

VBA_Extensibility_1.jpg

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.

History

First public release.

License

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)

United States United States

Member

Hector J. Rivas has 25+ years of experience managing hardware and software development under many different operating systems, platforms and languages. He has developed microcontroller interfaces and PC games; authored computer based training lessons and delivered fully functional financial and administrative data-intensive applications, as well as image processing and other calculation-intensive applications. Mr. Rivas has also managed Y2K remediation, large scale platform migration and Web site projects, from R&D to actual deployment.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralProblem Pinmembershutao9:58 10 May '10  
GeneralRe: Problem PinmemberMuller.Ben18:25 5 Jun '10  
GeneralMy vote of 1 PinmemberAxelM21:54 21 Feb '10  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 17 Feb 2010
Article Copyright 2010 by hector.j.rivas
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid