VBA Compatibility
VBA Padlock compiles VBA (Visual Basic for Applications) into protected bytecode executed inside your secured DLL.
Use this page as your practical compatibility guide: what works, what does not, and what to adapt when moving from standard Office VBA to compiled scripts.

Compatibility at a glance
Section titled “Compatibility at a glance”| Area | Status | Notes |
|---|---|---|
Core VBA language (Dim, loops, procedures, arrays, Enum, Type) | ✅ Fully supported | Includes dynamic arrays and recursion |
| Built-in VBA functions | ✅ Broad coverage | See Script Functions Reference |
Office object model (Application) | ✅ Fully supported | Use explicit Application. prefix in protected code |
COM automation (CreateObject) | ✅ Supported | Scripting.Dictionary, ADODB.*, etc. |
Windows API Declare | ⚠️ Opt-in | Disabled by default; enabled on request — see DLL Calls |
| Class modules / UserForms | ❌ Not supported | Use standard modules + Padlock dialogs |
Supported VBA features
Section titled “Supported VBA features”Language Fundamentals
Section titled “Language Fundamentals”| Feature | Supported | Notes |
|---|---|---|
Variables (Dim, Private, Public) | Yes | All standard data types |
Constants (Const) | Yes | |
| Arrays (fixed and dynamic) | Yes | ReDim, ReDim Preserve supported |
User-defined types (Type) | Yes | |
Enumerations (Enum) | Yes | |
Option Explicit | Yes | Recommended |
Option Compare | Yes | Binary and Text |
Comments (' and Rem) | Yes |
Data Types
Section titled “Data Types”| Type | Supported | Notes |
|---|---|---|
Boolean | Yes | |
Byte | Yes | |
Integer | Yes | |
Long | Yes | |
LongLong | Yes | 64-bit integer |
Single | Yes | |
Double | Yes | |
Currency | Yes | |
String | Yes | Variable-length strings |
Date | Yes | Stored as Double internally |
Variant | Yes | Full support |
Object | Yes | COM objects via Application and CreateObject() |
Control Flow
Section titled “Control Flow”| Feature | Supported |
|---|---|
If...Then...Else...End If | Yes |
Select Case | Yes |
For...Next | Yes |
For Each...Next | Yes |
Do...Loop (While/Until) | Yes |
While...Wend | Yes |
GoTo | Yes |
GoSub...Return | Yes |
On Error GoTo | Yes |
On Error Resume Next | Yes |
Exit Sub/Function/For/Do | Yes |
End | Yes |
Procedures
Section titled “Procedures”| Feature | Supported | Notes |
|---|---|---|
Sub | Yes | |
Function | Yes | |
Property Get/Let/Set | Yes | |
Optional parameters | Yes | |
ParamArray | Yes | |
ByRef / ByVal | Yes | ByRef is default |
| Recursive calls | Yes | |
Declare (DLL calls) | Opt-in | Disabled by default; see DLL Calls |
| Module-level code | Yes | Executed on module initialization |
Operators
Section titled “Operators”All standard VBA operators are supported:
- Arithmetic:
+,-,*,/,\(integer division),Mod,^ - Comparison:
=,<>,<,>,<=,>= - Logical:
And,Or,Not,Xor,Eqv,Imp - String:
&(concatenation),Like(pattern matching) - Other:
Is,IsNot,TypeOf...Is
Built-in Functions
Section titled “Built-in Functions”VBA Padlock includes a comprehensive set of built-in functions that mirror standard VBA functions. See the Script Functions Reference for the complete list, including:
- String functions (
Mid,Left,Right,InStr,InStrRev,Replace,Split,Join,Trim,LTrim,RTrim,UCase,LCase,StrComp,StrReverse,Chr,ChrW,Asc,AscW,Hex,Space,String,Format) - Math functions (
Abs,Sqr,Sin,Cos,Tan,Exp,Round,Int,Fix,Sgn,Rnd) - Date functions (
Now,Date,Time,DateAdd,DateDiff,Weekday,WeekdayName,MonthName,Year,Month,Day,Hour,Minute,Second) - Type functions (
TypeName,VarType,IsObject,IsMissing,IsArray,IsDate,IsEmpty,IsNull,IsNumeric) - Conversion functions (
CInt,CLng,CDbl,CSng,CStr,CBool,CByte,CDate,CCur) - Flow functions (
IIf,Choose,Switch) - Utility functions (
Array,DoEvents,RGB,Nz,LBound,UBound,Randomize)
Constants templates and script references
Section titled “Constants templates and script references”VBA Padlock ships with a rich set of ready-to-use script libraries containing thousands of Office constants and utility functions. These .bas template files can be added to your project via the Templates button and referenced from any module using the References directive.
See the Script Libraries & Constants reference for the full catalog of available libraries, usage instructions, and code examples.
Office Object Model Access
Section titled “Office Object Model Access”Compiled scripts have full access to the host Office application through the Application object. You can manipulate worksheets, documents, presentations, and databases exactly as you would in regular VBA.

Protected code vs caller code (recommended workflow)
Section titled “Protected code vs caller code (recommended workflow)”- Write sensitive logic in protected modules (inside VBA Padlock Studio).
- Use explicit
Application.references for host objects. - Call protected routines from Office VBA through
VBAPL_Execute(...).
Examples in Protected Code
Section titled “Examples in Protected Code”These examples show how you should write your code inside the VBA Padlock Editor to ensure it can be compiled successfully:
' PROTECTED CODE (Inside VBA Padlock)Sub WriteToCell(CellAddress, Value) ' Correct: uses Application. Application.ActiveSheet.Range(CellAddress).Value = ValueEnd Sub
Function ReadFromCell(CellAddress) ' Correct: uses Application. ReadFromCell = Application.ActiveSheet.Range(CellAddress).ValueEnd Function' PROTECTED CODE (Inside VBA Padlock)Function GetDocumentInfo() Dim Doc Set Doc = Application.ActiveDocument GetDocumentInfo = "Document: " & Doc.Name & Chr(13) & _ "Pages: " & Doc.ComputeStatistics(2)End Function' PROTECTED CODE (Inside VBA Padlock)Function GetDatabaseInfo() Dim DB Set DB = Application.CurrentDb GetDatabaseInfo = "Database: " & DB.Name & Chr(13) & _ "Queries: " & DB.QueryDefs.CountEnd Function' PROTECTED CODE (Inside VBA Padlock)Function AddTitleSlide(Title, Subtitle) Dim Pres, Sld, SlideIndex Set Pres = Application.ActivePresentation SlideIndex = Pres.Slides.Count + 1 Set Sld = Pres.Slides.Add(SlideIndex, 1) ' ppLayoutTitle = 1 Sld.Shapes.Title.TextFrame.TextRange.Text = Title Sld.Shapes.Placeholders(2).TextFrame.TextRange.Text = Subtitle AddTitleSlide = SlideIndexEnd FunctionThe Caller Side (Office VBE)
Section titled “The Caller Side (Office VBE)”On the other hand, the code you write in the Excel/Word VBA Editor (Alt+F11) acts as a simple bridge. It does not need any special prefixes:
' CALLER CODE (Inside Excel/Word VBE)Sub RunMyProtectedCode() ' Regular VBA call to the compiled function Call VBAPL_Execute("WriteToCell", "A1", "Hello!")End Sub
COM Object Creation
Section titled “COM Object Creation”CreateObject() is supported in compiled scripts. You can create and use COM objects such as Scripting.Dictionary, ADODB.Connection, ADODB.Stream, etc.
Function RemoveDuplicates(ColumnIndex) Dim Dict Set Dict = CreateObject("Scripting.Dictionary")
Dim WS, LastRow, Row, Key Set WS = Application.ActiveSheet LastRow = WS.Cells(WS.Rows.Count, ColumnIndex).End(-4162).Row ' xlUp
For Row = 2 To LastRow Key = CStr(WS.Cells(Row, ColumnIndex).Value) If Not Dict.Exists(Key) Then Dict.Add Key, Row End If Next Row
RemoveDuplicates = Dict.CountEnd FunctionLimitations
Section titled “Limitations”These limitations are by design and keep the execution model secure and deterministic.
DLL Calls (Declare)
Section titled “DLL Calls (Declare)”VBA Padlock supports standard VBA Declare statements to call functions in external DLLs (Windows APIs and third-party DLLs). The syntax is identical to regular VBA:
Declare Function GetTickCount Lib "kernel32" () As LongDeclare Function GetComputerNameW Lib "kernel32" (ByVal lpBuffer As String, ByRef nSize As Long) As LongDeclare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)No Class Modules
Section titled “No Class Modules”Class modules (Class blocks) are not supported. Use standard modules with Sub, Function, and Type definitions instead.
No Forms (UserForms)
Section titled “No Forms (UserForms)”VBA UserForms are not available in compiled scripts. VBA Padlock provides its own built-in dialogs (activation, trial nag, EULA) configured through VBA Padlock Studio.
No Debug Object
Section titled “No Debug Object”The Debug.Print statement is not available. Use DebugPrint (from the Extension Library) instead, which outputs to OutputDebugString — visible with tools like DebugView or Visual Studio’s Output window.
' Instead of Debug.Print:DebugPrint "Value of x = " & xParameters for VBAPL_Execute
Section titled “Parameters for VBAPL_Execute”VBAPL_Execute supports any number of parameters. Calls with 0 to 4 arguments use optimized dedicated DLL exports, while calls with 5 or more arguments are automatically packed into an array and routed through ExecuteVBAFunctionN. This is handled transparently.
' Call with few parametersresult = VBAPL_Execute("Main|CalculatePrice", quantity, unitPrice)
' Call with many parameters (no limit)result = VBAPL_Execute("Reports|Generate", title, startDate, endDate, format, outputPath, includeCharts)When omitting the module name (e.g., VBAPL_Execute("MyFunction", arg1)), the function is searched in the default Main script. To call a function in another module, use the "ModuleName|FunctionName" syntax.

Differences from Standard VBA
Section titled “Differences from Standard VBA”String Handling
Section titled “String Handling”Compiled scripts use Unicode (UTF-16) strings internally, consistent with modern VBA. String comparisons default to binary comparison unless Option Compare Text is specified.
Error Handling
Section titled “Error Handling”On Error GoTo and On Error Resume Next work as expected. The Err object provides Number and Description properties. However, Err.Raise with custom error numbers should use values above 512 to avoid conflicts with built-in errors.
Module Initialization
Section titled “Module Initialization”Module-level code (code outside any Sub or Function) is executed when the module is first loaded. This happens on the first call to any function in that module.
Numeric Precision
Section titled “Numeric Precision”Integeris 16-bit signed (−32,768 to 32,767)Longis 32-bit signed (−2,147,483,648 to 2,147,483,647)LongLongis 64-bit signedDoublefollows IEEE 754 double-precision- Arithmetic rounding uses the
Roundfunction (arithmetic rounding, not banker’s rounding)
Supported Office Applications
Section titled “Supported Office Applications”VBA Padlock can protect projects for these Office applications:
| Application | File Types | Notes |
|---|---|---|
| Excel | .xlsm, .xlsb, .xla, .xlam | Most common use case |
| Word | .docm, .dotm | Documents and templates |
| Access | .accdb, .accde | Databases |
| PowerPoint | .pptm, .ppam | Presentations and add-ins |
All Office versions from Office 2016 through Office 2024 and Microsoft 365 desktop apps are supported and tested, in both 32-bit and 64-bit editions.




Best Practices
Section titled “Best Practices”-
Move sensitive logic into the compiled DLL. Business rules, pricing algorithms, license checks, and proprietary calculations should all be in compiled scripts — that’s where they are protected.
-
Use
Applicationfor Office interaction. Access worksheets, documents, ranges, and databases through theApplicationobject inside compiled scripts rather than passing data back and forth unnecessarily. -
Test with the Test Runner. Use VBA Padlock’s built-in Test Runner to validate your compiled scripts before publishing.
-
Use
Option Explicit. Declare all variables explicitly to catch typos and type mismatches at compile time. -
Keep modules focused. Split your code into multiple
.basmodules by responsibility. This improves readability and compilation diagnostics. -
Validate frequently with compilation + test run. Catch compatibility issues early in the build cycle.

See Also
Section titled “See Also”- Script Functions Reference — All built-in functions available in compiled scripts
- Script Libraries & Constants — Office constants and utility modules for compiled scripts
- VBA Bridge API Reference — Calling the DLL from Office VBA
- Project Format Reference — Project folder structure
- Code Editor — Writing and editing compiled scripts in VBA Padlock Studio