Skip to content

Batch Compilation and CI/CD Integration

You manage multiple VBA Padlock projects and want to automate the build process. This guide shows you how to compile projects from the command line, integrate with batch scripts, and set up CI/CD pipelines.

What you’ll learn:

  • How to build VBA Padlock projects from the command line
  • How to create batch scripts for multiple projects
  • How to integrate with CI/CD systems
  • How to verify build artifacts

Time needed: 15 minutes


Terminal window
VBAPadlock.exe "<office-file>" [switches]

The first argument is the path to the Office source file (.xlsm, .docm, .accdb, .pptm, etc.). The associated .vbapadlock project folder must be in the same directory.

SwitchTypeDescription
-c or --compileFlagCompile the project and build all DLLs (32-bit, 64-bit, and satellite).
-q or --quitFlagQuit the application after compilation.
-s or --silentFlagHide the main window (headless mode). Implies --quit when combined with --compile.
--publishFlagPerform a final/publish build. Disables HotLoading for production distribution.
--log:<path>StringSave the compilation log to the specified file path.
Exit CodeConstantMeaning
0EXIT_SUCCESSCompilation completed successfully. All DLLs have been built.
1EXIT_INVALID_ARGUMENTSInvalid command-line arguments or missing source file path.
2EXIT_FILE_NOT_FOUNDThe specified Office source file was not found.
3EXIT_PROJECT_LOAD_ERRORThe project could not be loaded (missing .vbapadlock folder, corrupt project.xml, etc.).
4EXIT_COMPILE_ERRORVBA compilation failed (syntax error) or DLL build failed.

Without any switches, passing just a file path opens the project in VBA Padlock Studio — no compilation is triggered:

Terminal window
VBAPadlock.exe "C:\Projects\MyApp\MyWorkbook.xlsm"

Create a batch script that builds one project and checks the result:

Terminal window
@echo off
setlocal
set VBAPADLOCK="C:\Program Files\VBA Padlock\VBAPadlock.exe"
set PROJECT="C:\Projects\MyApp\MyWorkbook.xlsm"
echo Building %PROJECT%...
%VBAPADLOCK% %PROJECT% --compile --silent --log:build.log
if %ERRORLEVEL% NEQ 0 (
echo BUILD FAILED with exit code %ERRORLEVEL%
type build.log
exit /b %ERRORLEVEL%
)
echo Build successful.
endlocal

Build several projects in sequence:

Terminal window
@echo off
setlocal enabledelayedexpansion
set VBAPADLOCK="C:\Program Files\VBA Padlock\VBAPadlock.exe"
set PROJECTS_DIR=C:\Projects
set FAILED=0
for %%P in (
"%PROJECTS_DIR%\AppA\Workbook.xlsm"
"%PROJECTS_DIR%\AppB\Report.docm"
"%PROJECTS_DIR%\AppC\Database.accdb"
) do (
echo.
echo === Building %%~nxP ===
%VBAPADLOCK% %%P --compile --silent --log:%%~nP_build.log
if !ERRORLEVEL! NEQ 0 (
echo FAILED: %%~nxP
set /a FAILED+=1
) else (
echo OK: %%~nxP
)
)
echo.
if %FAILED% GTR 0 (
echo %FAILED% project(s) failed to build.
exit /b 1
) else (
echo All projects built successfully.
)
endlocal

After building, verify the output DLLs exist:

Terminal window
@echo off
set PROJECT_DIR=C:\Projects\MyApp
:: Check all three DLLs exist
if not exist "%PROJECT_DIR%\bin\MyWorkbookrun32.dll" (
echo ERROR: Missing 32-bit runtime DLL
exit /b 1
)
if not exist "%PROJECT_DIR%\bin\MyWorkbookrun64.dll" (
echo ERROR: Missing 64-bit runtime DLL
exit /b 1
)
if not exist "%PROJECT_DIR%\bin\MyWorkbook.dll" (
echo ERROR: Missing satellite DLL
exit /b 1
)
echo All build artifacts verified.

  • VBA Padlock must be installed on the build machine.
  • The Office file and its .vbapadlock project folder must be in the repository.
  • The bin\ output directory should be in .gitignore.

Example: GitHub Actions (Self-Hosted Runner on Windows)

Section titled “Example: GitHub Actions (Self-Hosted Runner on Windows)”
name: Build VBA Padlock Projects
on: [push]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Build Project
shell: cmd
run: |
"C:\Program Files\VBA Padlock\VBAPadlock.exe" "%GITHUB_WORKSPACE%\MyWorkbook.xlsm" --compile --silent --publish --log:build.log
if %ERRORLEVEL% NEQ 0 (
type build.log
exit /b %ERRORLEVEL%
)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: protected-app
path: |
MyWorkbook.xlsm
bin/
- name: Upload build log
if: always()
uses: actions/upload-artifact@v4
with:
name: build-log
path: build.log

MyProject/
├── MyWorkbook.xlsm ← Office file
├── MyWorkbook.vbapadlock/ ← Project folder (commit this)
│ ├── project.xml
│ ├── Main.bas
│ └── Helpers.bas
├── build.bat ← Build script
├── .gitignore ← Excludes bin/
└── bin/ ← Output (generated, do not commit)

When --log:<path> is specified, the log file is a plain UTF-8 text file containing all compilation messages. Each line is prefixed with its severity level:

VBA Padlock Compilation Log - 2026-02-12 14:30:00
------------------------------------------------------------
[Info] Validating project settings...
[Info] Compiling scripts...
[Info] Built 32-bit runtime DLL: C:\Projects\bin\MyWorkbookrun32.dll
[Info] Built 64-bit runtime DLL: C:\Projects\bin\MyWorkbookrun64.dll
[Info] Built satellite DLL: C:\Projects\bin\MyWorkbook.dll
[Success] Compilation completed successfully.

The log file is created in all exit paths — including error scenarios — so it can always be inspected after a build.

  • The Office document and its .vbapadlock project folder must be in the same directory.
  • VBA Padlock must have access to its dll_templates\ subdirectory (part of the installation).
  • All VBA script modules (.bas files) must be saved as UTF-8. The compiler reads scripts using UTF-8 encoding. Using a different encoding may cause compilation errors or incorrect string handling.

Troubleshooting

Common build issues and solutions.

Read more →