Skip to main content

VBA to DLL - How VBA Compilation Works

VBA Padlock extracts your VBA macros and compiles them into native 32-bit and 64-bit Windows DLLs. In the protected copy, your source code is replaced by bytecode that cannot be decompiled.

What Is VBA to DLL Compilation?

VBA to DLL compilation is the process of transforming your VBA source code into native Windows DLL files containing compiled bytecode. Unlike obfuscation (which scrambles readable code) or password protection (which hides it behind a removable flag), compilation produces a completely different binary format - the original VBA simply does not exist anymore.

VBA Padlock handles the entire pipeline: extraction, analysis, bytecode generation, DLL packaging, code signing, and wrapper and VBA Bridge generation. You open your existing Office file, review the analysis, click Produce, and receive a protected copy with ready-to-distribute signed DLLs. Your source file is never modified.

The Compilation Pipeline

Four steps from your existing Office file to a protected copy with signed, distributable DLLs.

1

Open Your Office File

Open your existing workbook, document, database, or presentation. VBA Padlock extracts your macros and analyzes them procedure by procedure.

2

Review the Analysis

The Protection Review shows what moves into the compiled DLL and what stays in the document by design - event handlers, UserForms, document code.

3

Produce the Protected Copy

Click Produce. Your procedures are compiled into bytecode in a satellite DLL; wrappers with the same names and signatures plus the VBA Bridge are injected into a protected copy. Your source file is never modified.

4

Distribute Signed DLLs

Ship the protected copy with its bin/ folder: Authenticode-signed 32-bit and 64-bit runtime DLLs plus the satellite DLL containing your compiled code.

The Compilation Process in VBA Padlock

From the extracted code to compiled DLL output - see the process in action.

VBA Padlock Studio showing extracted VBA code with protection markers
The extracted VBA in VBA Padlock Studio - protection markers show what compiles into the DLL.
VBA Padlock compilation success dialog showing generated DLL files
Compilation complete - signed 32-bit and 64-bit DLLs ready for distribution.

What VBA Padlock Produces

After you click Produce, the output folder contains the protected copy of your Office file and a bin/ directory with three DLL files. This is the complete distribution package - nothing else is needed.

MyProject/
├── MyProject_protected.xlsm     ← Protected copy (wrappers + VBA Bridge)
└── bin/                         ← DLL directory
    ├── MyProjectrun32.dll       ← 32-bit runtime (Authenticode-signed)
    ├── MyProjectrun64.dll       ← 64-bit runtime (Authenticode-signed)
    └── MyProject.dll            ← Satellite DLL (compiled bytecode)
File Purpose Signed
{Name}run32.dll Runtime for 32-bit Office
{Name}run64.dll Runtime for 64-bit Office
{Name}.dll Satellite DLL with compiled bytecode Optional

Before and After Compilation

Left: your original VBA, extracted and compiled into the DLL. Right: what users see in the protected copy - generated wrappers and the Bridge module, no business logic.

Your Code (compiled into DLL)
Function ProcessData(InputRange, OutputCell)
    Dim Total As Double
    Dim i As Long

    For i = 1 To InputRange.Rows.Count
        Total = Total + InputRange.Cells(i, 1)
    Next i

    Application.ActiveSheet _
        .Range(OutputCell).Value = Total
    ProcessData = Total
End Function
What Users See (VBA Editor)
' VBA Bridge - auto-generated by VBA Padlock
' This module loads the compiled DLL and
' routes function calls. No business logic.

Sub RunProcessData()
    Dim Result As Variant
    Result = VBAPL_Execute( _
        "ProcessData", _
        Range("A1:A100"), "B1")
    MsgBox "Total: " & Result
End Sub

Produce and Distribute

One click on Produce compiles the DLL, generates the wrappers and VBA Bridge, and saves a protected copy of your file.

VBA Padlock Produce dialog generating the protected copy and signed DLLs
Produce dialog - compile the DLL and generate the protected copy in one step.
VBA Bridge module auto-generated by VBA Padlock
Auto-generated VBA Bridge module - injected into the protected copy together with the delegating wrappers.

What DLL Compilation Gives You

Compilation is not just about protection - it's a complete distribution framework for professional VBA applications.

Source Code Removed

Your VBA logic is compiled into bytecode. There is no readable business logic left in the protected copy or in the DLL - the VBA Editor shows only thin wrappers and the Bridge module.

COM Access Preserved

All COM object calls (Application, Workbooks, Documents, Ranges, Recordsets) work exactly as before. The bytecode interpreter handles COM interop transparently.

Digitally Signed Output

Runtime DLLs are Authenticode-signed by G.D.G. Software, so Windows names the publisher rather than warning about an unknown one.

Dual Architecture

Every project produces both 32-bit and 64-bit DLLs. The VBA Bridge loads the correct runtime automatically based on the user's Office installation.

Built-in Licensing

Add license keys, hardware locking, trial periods, and online activation - all compiled into the DLL. No extra code needed in your Office file.

Zero Dependencies

End users need only Microsoft Office (2016+). No runtime, no .NET Framework, no admin rights. Ship the protected copy with the bin/ folder and you're done.

Ready to Monetize Your VBA Projects?

Download VBA Padlock and start selling protected Office solutions. One-time purchase, no royalties, no subscription.

Frequently Asked Questions

What does 'VBA to DLL compilation' actually mean?
VBA to DLL compilation transforms your VBA source code into bytecode stored inside a native Windows DLL. The original VBA no longer exists - it is replaced by a binary representation that cannot be decompiled back to readable source code.
Does the compiled DLL work with both 32-bit and 64-bit Office?
Yes. VBA Padlock produces two runtime DLLs - one for 32-bit Office and one for 64-bit Office. The VBA Bridge automatically loads the correct one based on the running Office version. You distribute both, and the right DLL is used transparently.
Can my compiled code still use the Office object model (COM)?
Yes. Your compiled code retains full access to the Office COM object model - Application, Workbooks, Documents, Recordsets, and all other objects. The bytecode interpreter bridges COM calls transparently.
Is the compiled DLL digitally signed?
Yes. The runtime DLLs are Authenticode-signed by G.D.G. Software, so Windows names the publisher instead of showing an unknown-publisher warning, and antivirus engines have a known publisher to recognize. You can optionally sign the satellite DLL with your own certificate.
How does performance compare to native VBA?
Compiled code runs through VBA Padlock's bytecode interpreter, which is comparable in speed to the native VBA runtime. For business applications - data processing, document generation, licensing checks - the difference is negligible.