How to compile VBA code into native Windows DLL
Prepare your Excel environment and your file with VBA code (workbook or Excel add-in) for VBA compilation.
You need to have the desktop Microsoft Windows OS 7 or higher and Microsoft Excel 2007 or higher installed on your computer.
After passing through these 10 steps your VBA code will be compiled.
1. Download the VbaCompiler for Excel on your computer.
2. Install the VbaCompiler for Excel.
To install the product you need to start VbaCompiler4Excel.msi file and follow the installer wizard steps.
3. Enable “Trust access to the VBA project object model” MS Excel option by following the path:
Excel Options >> Trust center >> click button “Trust Center Settings…” >> Macro Settings >> enable check box “Trust access to the VBA project object model”
4. Examine your vba code for syntax errors.
To do that you need to run embedded Visual Basic code analyser by this path:
VBA Project window (Alt + F11) >> Main menu >> Debug >> Compile VBA project
if after running “Compile VBA Project” Excel found a syntax error, then you need to fix it and
repeat this step again until the “Compile VBA Project” menu item is greyed out.
IMPORTANT NOTE: When you finished this step your VBA code is not compiled yet.
5. Make backup copy of the file you are going to compile.
The most simple way is copying the file into another folder on your computer.
NOTE: The VbaCompiler for Excel doesn’t change your original file.
However it is a good practice to have a backup copy of your original file.
6. Remove the VBA Project password in the file you are going to compile.
You can apply it later, on VBA Project of the file with compiled vba code.
This step is required because the VbaCompiler has to get full access to the VBA code.
7. Run VbaCompiler for Excel by clicking the shortcut on Windows desktop.
8. Enter the name of file you want to compile.
The easiest way is to select by clicking button […] next to edit field and selecting the file in the dialogue window.
9. Enter the output folder where resulting files/modified excel file and Windows DLL with compiled VBA code will be located after compilation.
The easiest way is to select a folder by clicking button […] next to edit field and selecting the folder in the dialogue window.
10. Click ‘Compile’ main menu item and wait until VBA code compilation is finished.