How to compile VBA code into native Windows DLL
Prepare your Excel environment and your file that contains VBA code (be it a workbook or an 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 going 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 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 the embedded Visual Basic code analyzer, located by following 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 have finished this step your VBA code is not compiled yet.
5. Make backup copy of the file you are going to compile.
The simplest way of doing this is to copy 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 to the VBA Project of the file with the 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 the Windows desktop.
8. Enter the name of file you want to compile.
The easiest way is to select the file by clicking the […] button which is 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 the […] button which is next to edit field and selecting the folder in the dialogue window.
10. Click the ‘Compile’ main menu item and wait until VBA code compilation is finished.