VBA is a great programming language for Office developers, but there’s no doubt that it’s imperfect. Whether it’s existing language features that need improving, or new ones that are missing entirely, Microsoft hasn’t been doing much for a very long time.
Visual Basic Editor (VBE) has plenty of missing features, too. For example, it has no automatic indentation and no refactoring capabilities. While some of these features are available through third-party add-ins, it would be great to have them built into the editor itself. Here’s my selection of top missing features.
#1. Automatic indentation
One of the most controversial things about VBE is that it’s code editor is very basic, whether you like it or not. I have to admit, coming back from another code editor, such as Visual Studio or Sublime, is sometimes a major inconvenience.
Wouldn’t it be great if code could be automatically re-indented?
I currently use Visual Studio for this. To re-indent messy code, I use the
Format Document command.
#2. Collapse Function and Sub procedures
Most modern code editors support collapsing functions, so as to ease the code navigation. Unfortunately, there’s no such feature in VBA Editor.
#3. Class explorer
A class explorer, such as the one found in Visual Studio, would be an awesome asset in VBE. If you’re into OOP, classes can pile up really quickly. Having a good class explorer right inside VBE would greatly enhance navigation in projects that contain many of them.
Visual Studio saw the introduction of refactoring capabilities, long time ago. It quickly became an indispensable feature of power users, as well as beginners. While refactorings were always available through some third-party add-ins, it would be great to have those features built into the editor itself.
For example, it should be easy to rename a Sub or Function procedure. It should also be easy to extract a method, or to reorder parameters. Luckily, Rubberduck VBA makes our life easier by providing such missing functionality.
#5. Code metrics
A neat feature in Visual Studio is code metrics. It analyses different aspects of your code, such as number of lines of code, and length and complexity of procedures (also called cyclomatic complexity). A developer can look at these metrics and use them as a guide to improve his code.
#6. Unit testing
People comfortable with test driven development love unit tests, and I can understand why. It helps to create code that is more robust, resilient and reliable. Most modern development environments have some sort of support for unit tests, in one shape or another. Unfortunately there’s no such thing in VBA, but I wish there was!
#7. Source control
Wouldn’t it be great if you could easily integrate your project with a source control repository, such as GitHub? If you’re keen on doing this, right now you need to manually export all your code (including modules and classes), then upload to GitHub. By now, this is a very common scenario, and this should be standard in the Visual Basic Editor.
In this article I outlined the features I would like to see in VBA Editor: automatic indentation, collapsing Function and Sub procedures, class explorer, refactorings, code metrics, unit testing and source control.
Do you agree? Are there any features you would like to see in the VBE code editor? Share your thoughts in the comments below!