How to protect VBA Project and code with VBA password
VBA Password protection
To prevent your source code from prying eyes you can use password protection of the VBA Editor (VBE) and VBA Project in your MS Excel workbook. It is a standard technique to protect your macros in all MS Office applications which is available by default.
You can protect VBA Project and VBE in Excel by just following these steps:
1. Open VBA Editor in Excel by pressing Alt+F11 or selecting “Visual Basic” item in the Developer dropdown menu.
2. In the VBA Editor menu select the “Tools” menu item and click on the “VBAProject properties”.
3. In the opened “VBAProject – Project Properties” window, select the “Protection” tab.
4. Check on the “Lock project for viewing.
5. Enter your password and confirm the password.
6. Click OK and save your workbook.
When you have protected your macros using those steps, each time when you try to get access to your workbook VBA Project you will be prompted for a password.
After entering the correct password, the VBA editor will be available for editing your source code.
VBA Password cracking
Important Notice: The VBE password protection is not strong protection. It will not stop malefactors from viewing or copying of your VBA code.
There are a lot of tools, many of which happen free or easily available as commercial tools on the market, that can be used to remove or recover the VBE password in the workbook.
You need to consider the VBE password protection for your projects only in the case of protection against the accidental changes of your code by customers or consumers.
If you want to be sure that nobody can see or copy your source code, this approach doesn’t meet your needs.
VBA Password alternatives
Many methods exist to protect Excel macros from being viewed and copied, and many are available for free or as commercial products on the market. However, not all of them provide real protection of VBA code.
VBA obfuscation – is the technique which makes source code unreadable for humans, but the structure and logic of algorithms are not changed and, as a result, are left stored in the VBA project. This approach doesn’t protect your algorithms from being traced or copied.
Unviewable VBA approach – is a technique when VBA code is protected by different low-level workbook and VBA project modifications, which do not allow for your code to be viewable in Excel VBA Editor. This approach doesn’t protect your VBA code from viewing and copying because the source code may be easily reached by different methods and tools outside of Excel.
Translation of Visual Basic code to another compiling language – This approach assumes translation of the VBA language code into another, compiled language like C#, C, or C++. This approach is more effective for source code protection but is much more labor intensive, time consuming, and significantly more error prone.
Please read more information about and familiarize yourself with the strengths and weaknesses of the different possible approaches of VBA protection.
The best alternative is VbaCompiler for Excel
The DoneEx VbaCompiler for Excel is the best alternative for VBE password protection because of the following:
- VbaCompiler converts your VBA code into C-language code and compiles it into a Windows DLL in a fully automated manner without any of your participation in the process.
- VbaCompiler doesn’t change your original workbook because it works with copy of the workbook.
- All VBA code in the compiled workbook is converted into a Windows DLL file, making it removed from the VBA project and unavailable to anybody.
- There is no way to restore your VBA code from compiled Windows DLL.
- You do not need to know any other programming language except VBA in order to use the VbaCompiler for Excel.
- It supports all 32-bit and 64-bit Windows Excel versions since Excel 2007 and higher (including Excel in Office 365) as for compilation as for run-time.
- Your VBA code may work much faster after compilation.
- Compiled code works with the same logic and doing the same work as your original VBA code.
- You can distribute your workbook as a single Windows Installation package, which you can create by using our free DoneEx Installer Maker.
- With VbaCompiler for Excel you can license your workbook or Excel add-in and define on which computers your compiled workbook will be able to be opened.