VBA Password Security

VBA, or Visual Basic for Applications, is a popular feature in Microsoft Office which allows creation of macros, short programs which automate repetitive operations, or even create a complete application. VBA is available in Microsoft Word, Excel and Access, and even some non Microsoft applications but is most commonly used in Excel. You can apply passwords to VBA to protect the code from view or modification.

This article is about password security for VBA modules or macros, how to apply VBA passwords in Excel files and how you can recover password protected VBA modules if you lose the password.

Functions of VBA

VBA is a flexible programming language with an Integrated Development Environment (IDE) which allows the users to work with an application specific dialect of Microsoft Visual Basic (note: this is not compatible with VB.NET).

VBA can be used to customize user interfaces, automate repetitive operations, or even build a complete turnkey application, and is widely used in business for rapid development of small end user applications. Some companies build complex models using VBA as it is potentially very powerful.

VBA Password Security

Since VBA is a programming environment, a VBA macro may be quite complex, and form a bundled application. This may include a lot of sensitive processes or intellectual property that should be protected from casual viewing or modification.

Fortunately along with the normal data of a Word or Excel file, the macros or VBA modules can also be password protected. This can be used to provide a level of security against casual modification or viewing of your code, but is not particularly secure against a determined hacker.

How to password protect VBA in Excel

Though VBA passwords can be applied in Word and Access files, VBA passwords are more commonly used to protect VBA projects or macros in Excel files, generally to ensure protection of intellectual property or prevent unauthorised modifications to the macros.

In order to activate VBA password, first right click on the VBA module, then click on VBA Project Properties. Select the ‘Protection Tab’ from there. A new window will be opened. Put tick on ‘Lock Project for Viewing’ option. After that you need to insert the password in ‘Password to view Project Properties’ dialogue box. Click on ‘Ok’ to complete the whole process.

Make sure that you select a secure password if you want any level of protection. You can use the techniques discussed in the article: ‘Selecting a secure password’ to set up an effective and safe password.

VBA password recovery

If you ever accidentally lose your VBA password, or if you need to modify unsupported VBA code that is locked, then there is no need to worry. VBA passwords protect against casual inspection of your code, but they are not totally secure, and there are workarounds.

There are a number of effective VBA password recovery software packages available which allow you to gain access to the VBA module by bypassing the password protection. Essentially these work by replacing the existing password with a blank or a new password.

Ultimate Zip Cracker and ElcomSoft offer VBA password recovery software. You can learn more about this software in our VBA password recovery software article.

Protecting spreadsheet software

As you have read, it is relatively easy for someone with the right software to bypass the password protection, no matter how secure your password is. What can you do to protect your spreadsheet program source code?

You can write the code partially in VBA, and write the important parts in a compiled language, such as C, and turn the code into a DLL, which can be called from Excel. The DLL will not include the original C source code. The other benefit of this is that your code will run a lot faster than VBA.

Conclusion

VBA offers flexibility and power, and has a password protection option that protects against casual inspection or modification of your code.

This can’t really be regarded as secure however. There are a number of packages that allow you to replace the VBA password, or remove it altogether.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Tags: ,

2 Responses to “VBA Password Security”

  1. I wanted to comment and thank the author, good stuff

  2. Great article, thanks for the share. Blog bookmarked :)

Leave a Reply