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 much stronger solution to protect your VBA code from being stolen.
You can apply strong VBA protection to the Excel workbook VBA code by following these easy steps:
- Open the XCell Compiler compilation form by clicking on the “Compile” item in the DoneEx Excel ribbon menu.
This should cause the “VBA Protection Options” menu to pop up.
- Enable “Obfuscation” and “Literal Removing” options in the “VBA Protection Options” window and then click the “OK” button.
- Compile your workbook by clicking on the “Compile” button on XCell Compiler compilation form.
Now your VBA code is strongly protected, and your Excel formulas are protected with the best possible protection thanks to DoneEx XCell Compiler!
How VBA code protection works
To provide the strongest and most reliable VBA code copy protection, DoneEx XCell Compiler uses 2 different approaches which are combined into one solution when you select all of the options of “VBA Protection”.
Blocking access to VBA project and VBA code.
The “Unviewable VBA code” option blocks access to the VBA code, makes the VBA project unviewable, and disables VBA debug mode.
After applying this option, the VBA project and the VBA code will be unviewable and unavailable in the compiled application.
Any attempt to trace your VBA code will fail because VBA debug mode will be disabled.
VBA code modification.
Two options—the “Code obfuscation” option and the “Literals removing” option—modify the VBA code in a way that keeps VBA code functional but makes it scrambled and incomprehensible.
After applying the “Literals removing” option, the modified VBA code becomes tied to the XCell Compiler run-time library and will only be functional in the compiled application.
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 the 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 the compiled application.
- The VBA code is modified in such a way so that it is incomprehensible and unrecoverable.
Below you can see an example of the code transformation after applying both of the code modification options.
The original VBA code before applying ‘Protect VBA code’ option:
After applying both code modification options—the ‘Code obfuscation’ option and the ‘Literals removing’ option—the protect VBA code transforms into the code displayed in this screenshot: