DoneEx VbaCompiler for Excel
VBA Compiler for Excel converts VBA code of Microsoft Excel workbooks and Excel add-ins into binary code of a native Windows DLL file. After compilation your VBA code cannot be copied or recovered and has the highest level of protection from piracy. VBA Compiler is the best alternative to the VBA code protection approaches, such as VBA code obfuscation or standard MS Excel VBA project password protection. A compiled workbook or Excel add-in file is left with the original file extension and behaves the same way as the original file.
Main benefits of the VBA Compiler usage
- Bulletproof VBA code protection. It is practically impossible to recover your VBA code from a Windows DLL.
- It is impossible to research or trace the VBA code after compilation because it has been moved to the Windows DLL.
- The original MS Excel workbook or add-in file extension is left the same as before compilation.
- To use the VBA Compiler you do not need to have a knowledge of any other programming languages except VBA – Visual Basic for Application.
- VBA Compiler works with the copy of original file, and keeps the original file unchanged.
- VBA code conversion during compilation happens in automatic mode and doesn’t require any participation in process.
- You do not need to select which VBA functions you need to compile – all the VBA code methods (procedures, functions and properties) will be compiled with one mouse click on the “Compile” button.
How the VBA Compiler works
The DoneEx VbaCompiler transforms source VBA code into C-code and, in the final stage, the C-language code is compiled into a native Windows DLL file.
During compilation the transformation of source VBA code goes through several stages.
Stage 1. VbaCompiler parses and analyses source VBA code.
Stage 2. The product generates object code based on results of stage 1.
Stage 3. The product generates C-language code from the object code generated in stage 2.
Stage 4. The final stage of compilation – the product runs C-compiler to compile C-language code into Windows DLL.
After compilation VbaCompiler removes VBA code from the file and substitutes it with external DLL function calls.
Excerpt of the original VBA code before compilation
Function SOUNDEX(Surname As String) As String
' Developed by Richard J. Yanco
' This function follows the Soundex rules given at
Dim Result As String, c As String * 1
Dim Location As Integer
Surname = UCase(Surname)
' First character must be a letter
If Asc(Left(Surname, 1)) < 65 Or Asc(Left(Surname, 1)) > 90 Then
SOUNDEX = ""
' St. is converted to Saint
If Left(Surname, 3) = "ST." Then
Surname = "SAINT" & Mid(Surname, 4)
' Convert to Soundex: letters to their appropriate digit,
' A,E,I,O,U,Y ("slash letters") to slashes
' H,W, and everything else to zero-length string
Result = Left(Surname, 1)
For Location = 2 To Len(Surname)
Result = Result & Category(Mid(Surname, Location, 1))
' Remove double letters
Location = 2
Do While Location < Len(Result)
If Mid(Result, Location, 1) = Mid(Result, Location + 1, 1) Then
Result = Left(Result, Location) & Mid(Result, Location + 2)
Location = Location + 1
' If category of 1st letter equals 2nd character, remove 2nd character
If Category(Left(Result, 1)) = Mid(Result, 2, 1) Then
Result = Left(Result, 1) & Mid(Result, 3)
' Remove slashes
For Location = 2 To Len(Result)
If Mid(Result, Location, 1) = "/" Then
Result = Left(Result, Location - 1) & Mid(Result, Location + 1)
' Trim or pad with zeroes as necessary
Select Case Len(Result)
SOUNDEX = Result
Case Is < 4
SOUNDEX = Result & String(4 - Len(Result), "0")
Case Is > 4
SOUNDEX = Left(Result, 4)
Private Function Category(c) As String
' Returns a Soundex code for a letter
Select Case True
Case c Like "[AEIOUY]"
Category = "/"
Case c Like "[BPFV]"
Category = "1"
Case c Like "[CSKGJQXZ]"
Category = "2"
Case c Like "[DT]"
Category = "3"
Case c = "L"
Category = "4"
Case c Like "[MN]"
Category = "5"
Case c = "R"
Category = "6"
Case Else 'This includes H and W, spaces, punctuation, etc.
Category = ""
The same VBA code after compilation with VBA Compiler
As you can see that content of the VBA function bodies is moved to the compiled DLL file and substituted by calls of DLL functions.