Office Code Readability

This post discusses ways to ease your ability to read someone else’s code.

Did you ever look at someone’s Office macro and think to yourself, “Boy, this is hard to read”? I know I have, and it’s particularly bad when he (or she) is using line numbers. Though line numbers help in identifying errors during debugging, they become more of an irritant when you are trying to read the code for some other purpose. Of course, we want to be able to debug, and we want to be able to read – can we have it both ways? – yes, we can!

To make the code more readable, we could go thru every line of code and manually delete each line number, but that would be quite a chore. Or, you could print out (or save) a version of the code before adding-in the line numbers. Because code changes so often, managing both versions seems like an impractical solution as well.

To make the code more readable, we could go thru every line of code and manually delete each line number, but that would be quite a chore. Or, you could print out (or save) a version of the code before adding-in the line numbers. Because code changes so often, managing both versions seems like an impractical solution as well.

The best way I’ve found to quickly remove line numbers is to use this handy little tool:

VBA Line Numbers with CodeLiner

It’s pretty cool – once installed, you will see a new toolbar in your VBA Editor, whether it’s Excel, Access or Word. The toolbar has a button that simply hides all line numbers in your project! With all the line numbers hidden, the code has instantly become much more readable. Thankfully, there is another button on that same toolbar that will re-insert the line numbers, when you want to go back to debugging your code.

So, code happy with readable code, everybody!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s