How to protect VBA code and VBA project
By default, Microsoft Excel offers VBA project password protection as a way to protect VBA code. This method of VBA code protection is weak and can be easily cracked. The DoneEx XCell Compiler provides a much better and stronger solution to protect your VBA code from theft.
You can apply strong VBA protection to Excel workbook VBA code by following these easy steps:
- Open XCell Compiler compilation form by selecting “Compile” item in DoneEx Excel ribbon menu.
- Enable “Protect VBA” option.
- Enable “Obfuscation” and “Literal Removing” options on the “VBA Protection Options” window.
- Click “OK” button.
- Compile workbook by clicking “Compile” button on XCell Compiler compilation form.
How VBA code protection works
To provide the most strong and reliable VBA code copy protection, DoneEx XCell Compiler
uses 2 different approaches which are combined into one solution when you select all options of ‘VBA Protection’.
Blocking access to VBA project and VBA code.
Option ‘Unviewable VBA code’ blocks access to the VBA code, makes VBA project unviewable and disables VBA debug mode.
After applying this option, VBA project and VBA code will be unviewable and unavailable in compiled application.
Anybody who tries to see your VBA code will only see this message. Any attempt to trace your VBA code will fail because VBA debug mode will be disabled.
VBA code modification.
Two options, the ‘Code obfuscation’ and ‘Literals removing’, modify the VBA code in a way that keeps VBA code functional but makes it scrambled and incomprehensible.
After applying all 3 options simultaneously you will get the strongest VBA code protection available, which has the following advantages:
- The VBA code is unviewable and inaccessible from Excel VBA project.
- The VBA debug mode is disabled, so it is impossible to trace the VBA code.
- All comments and empty lines are removed from the VBA code.
- The VBA code with removed literals will not work outside of compiled application.
- The VBA code is modified so it is incomprehensible and unrecoverable.
Below you may see an example of code transformation after applying both code modification options.
Original VBA code:
After applying both code modification options, the ‘Code obfuscation’ option and the ‘Literals removing’ option, the VBA code is: