Skip to content

Protect a Word Document

You’ve automated Word with VBA (document generation, formatting, mail-merge-style reports), and now you want to ship it without shipping your source code. In this tutorial you’ll protect a macro-enabled Word document with the automatic workflow: open, review, produce. We’ll use the bundled DocumentBuilder example as our guide, but every step applies unchanged to your own .docm or .dotm.

What you’ll get:

  • A protected copy (DocumentBuilder_protected.docm) whose macros work exactly as before
  • A compiled, encrypted DLL containing your VBA logic
  • (Optional) Licensing with activation keys

Time needed: 10-15 minutes


  1. Launch VBA Padlock and click Open Office File (Ctrl+O) in the Protect tab

  2. Select your document: for this tutorial, DocumentBuilder.docm, which contains a DocBuilder module (heading/list/table builders, placeholder replacement, PDF export) and a Demo module driving it

  3. VBA Padlock extracts the VBA modules directly from the document (macros stay disabled) and analyzes them automatically

The Project Explorer fills with your modules and their verdict badges, and a DocumentBuilder.vbapadlock project folder appears next to the file.


Click View Report. For a document like DocumentBuilder you’ll see:

  • The DocBuilder and Demo standard modules: every procedure -> DLL.
  • ThisDocument: VBA (document); document-module code and event handlers (Document_Open, AutoOpen) always stay in the file.

If your code uses symbolic Word constants (wdFormatPDF, wdStyleHeading1, …), open References: WordConstants (~3,700 wd* constants) and OfficeConstants (mso*) are pre-selected for Word projects, so those names compile straight into the DLL. Alternatively, as the DocumentBuilder example does, you can declare the handful you use as module-level Const values; both approaches work.


  1. Optionally review Project Info (title, version, copyright, DLL name; defaults are pre-filled)

  2. Click Produce Protected Office File, or Test Run (Ctrl+F5) to produce and open it in Word

  3. On success, your folder contains:

DocumentBuilder\
├── DocumentBuilder.docm (your source - keep it private!)
├── DocumentBuilder.vbapadlock\ (project settings)
├── DocumentBuilder_protected.docm (ship this)
└── bin\
├── DocumentBuilderrun32.dll
├── DocumentBuilderrun64.dll
└── DocumentBuilder.dll

Your original document is never modified; Produce always writes to a copy.


  1. Open DocumentBuilder_protected.docm in Word and enable macros

  2. Press Alt+F8 and run the Demo_* macros (or RunAllDemos): headings, lists, tables, placeholder replacement, PDF export; everything behaves exactly as before

  3. Press Alt+F11: the DocBuilder procedures are now one-line wrappers calling the compiled DLL via the VBAPLBridge module; your logic is gone from the file

The protected Word document running compiled macros


Licensing works identically for every Office host:

  1. Licensing Features tab → Activation Settings: check “Activation key is required to run the protected VBA application”, optionally with hardware-locked keys

  2. Produce again: licensing rules are baked into the DLL, so the protected copy must be rebuilt

  3. Key Generator: generate a test key for your own Hardware ID and verify the activation dialog appears when you run a protected macro

VBA Padlock Activation Settings

The Excel tutorial’s licensing section covers the options in more detail; everything there applies to Word too.


Click Distribute in the Protect tab and create a ZIP or folder copy. The protected document and its bin\ folder must always travel together:

DocumentBuilder_v1.0.zip
├── DocumentBuilder_protected.docm
└── bin\
├── DocumentBuilderrun32.dll
├── DocumentBuilderrun64.dll
└── DocumentBuilder.dll

Protect an Excel Workbook

The most detailed host tutorial, including full licensing setup. Read the guide

Setting Up Licensing

Trial periods, activation keys, and hardware locking. Read the guide

Online Activation

Let users activate over the internet with your own server. Read the guide