2011-06-29

The Four VBA Options You Should Always Change

I have been teaching and using Visual Basic and VBA for almost 20 years. Although the classic Visual Basic is dead as a programming language, VBA is still being used for macros in Microsoft Office. There are four settings in the options that you should always change:

  1. Auto Syntax Check. Uncheck this option. If this option is checked, it brings up a syntax error message box every time that you leave a line with a syntax error. This gets in the way of programming, as you frequently want to move to other lines of code before completing the current line. When this option is off, the line will turn red if there is a syntax error. If you want to know why it is red, you can press F5 and then the message box will appear.
  2. Require Variable Declarations. Check this option. This option is actually misnamed. It should be named "Insert Option Explicit at the top of every new module you create". It has no impact on existing modules and it is the Option Explicit that actually makes variable declarations required.
  3. Notify Before State Loss. Check this option. This will give you a message box before committing any changes to a line that would require you to exit the debugger while debugging. This saves effort if you are doing a long debugging session, and make some minor change that would cause you to exit the debugger.
  4. Compile On Demand. Uncheck this option. This will compile all of your code, rather than just the next procedure that it needs to execute. This will find syntax errors in code that you are not executing. Machines are 1000 times faster than when this feature was put in place.
This creates the best environment for programming in VBA.

No comments :

Post a Comment