VBA Bridge API Reference
The VBA Bridge is a standard VBA module (VBADLLBridge) that VBA Padlock generates and injects into your Office file. It provides 19 public functions that your VBA code calls to interact with the compiled DLL. These functions handle code execution, licensing, activation, deactivation, online validation, EULA management, and security verification.
Naming Convention
Section titled “Naming Convention”All VBA Bridge functions are prefixed with VBAPL_. Internally, each function:
- Ensures the DLL is loaded and initialized (once per session)
- Calls the corresponding native DLL export (32-bit or 64-bit, selected automatically)
- Returns the result to your VBA code
Code Execution
Section titled “Code Execution”VBAPL_Execute
Section titled “VBAPL_Execute”Executes a compiled function inside the protected DLL.
Public Function VBAPL_Execute(ID As Variant, ParamArray Args() As Variant) As Variant| Parameter | Type | Description |
|---|---|---|
ID | Variant | Function identifier. Use "ModuleName|FunctionName" to call a function in a specific script module, or just "FunctionName" to call a function in the default Main script. Returns a runtime error if the function is not found. |
Args | ParamArray | Arguments to pass to the compiled function. Any number of arguments is supported. |
Returns: The value returned by the compiled function, or CVErr(xlErrValue) on error.
Example:
' Call a function with no parametersDim result As Variantresult = VBAPL_Execute("Main|Initialize")
' Call a function with parametersDim total As Varianttotal = VBAPL_Execute("Main|CalculatePrice", quantity, unitPrice, taxRate)
' Call a function without specifying the moduleDim msg As Variantmsg = VBAPL_Execute("GetWelcomeMessage", userName)
' Call a function with many parameters (no limit)Dim report As Variantreport = VBAPL_Execute("Reports|Generate", title, startDate, endDate, format, outputPath, includeCharts)License Status
Section titled “License Status”VBAPL_IsLicenseValid
Section titled “VBAPL_IsLicenseValid”Checks whether the current license is valid.
Public Function VBAPL_IsLicenseValid() As BooleanReturns: True if the license is valid or if activation is not required. False otherwise.
Example:
If Not VBAPL_IsLicenseValid() Then MsgBox "Your license is invalid or has expired.", vbExclamation VBAPL_ShowActivationEnd IfVBAPL_HasStoredLicense
Section titled “VBAPL_HasStoredLicense”Checks whether a license key is stored on this computer.
Public Function VBAPL_HasStoredLicense() As BooleanReturns: True if a license key has been registered. False if no license is stored.
Example:
If VBAPL_HasStoredLicense() Then MsgBox "Licensed to: " & VBAPL_GetRegisteredName()Else MsgBox "No license found. Please activate.", vbExclamationEnd IfVBAPL_GetRegisteredName
Section titled “VBAPL_GetRegisteredName”Returns the registered user name (licensee name) from the stored license.
Public Function VBAPL_GetRegisteredName() As StringReturns: The registered name string, or an empty string if no license is stored.
Example:
Dim licensee As Stringlicensee = VBAPL_GetRegisteredName()If licensee <> "" Then StatusBar.Text = "Licensed to " & licenseeEnd IfVBAPL_GetHardwareID
Section titled “VBAPL_GetHardwareID”Returns the Hardware ID for the current computer. This ID is unique per machine and per project.
Public Function VBAPL_GetHardwareID() As StringReturns: A formatted Hardware ID string (e.g., XXXXX-XXXXX-XXXXX), or an empty string on failure.
Example:
Dim hwid As Stringhwid = VBAPL_GetHardwareID()MsgBox "Your Hardware ID is: " & hwid & vbCrLf & _ "Send this to your vendor to receive a license key.", vbInformationActivation
Section titled “Activation”VBAPL_ShowActivation
Section titled “VBAPL_ShowActivation”Displays the activation dialog where the user can enter a license key.
Public Function VBAPL_ShowActivation(Optional ForceDisplay As Boolean = False) As Long| Parameter | Type | Default | Description |
|---|---|---|---|
ForceDisplay | Boolean | False | When True, shows the dialog even if a license is already active. |
Return codes:
| Value | Meaning |
|---|---|
1 | Activation successful |
0 | User cancelled or activation failed |
-1 | Error (DLL not initialized) |
-2 | Activation is not configured for this project |
Example:
Dim result As Longresult = VBAPL_ShowActivation()
Select Case result Case 1 MsgBox "Activation successful! Welcome.", vbInformation Case 0 MsgBox "Activation cancelled.", vbExclamation Case -2 ' Activation not configured — this project runs without a licenseEnd SelectTrial Mode
Section titled “Trial Mode”VBAPL_IsTrialMode
Section titled “VBAPL_IsTrialMode”Checks whether the application is currently running in trial mode.
Public Function VBAPL_IsTrialMode() As BooleanReturns: True if in trial mode. False if licensed or if trial mode is not configured.
VBAPL_GetTrialLimitLeft
Section titled “VBAPL_GetTrialLimitLeft”Returns the remaining trial allowance (days, runs, or days until expiration, depending on configuration).
Public Function VBAPL_GetTrialLimitLeft() As LongReturn codes:
| Value | Meaning |
|---|---|
>= 0 | Remaining trial limit |
-1 | DLL not initialized |
-2 | Not in trial mode |
Example:
If VBAPL_IsTrialMode() Then Dim daysLeft As Long daysLeft = VBAPL_GetTrialLimitLeft() MsgBox "Trial mode: " & daysLeft & " days remaining.", vbInformationEnd IfVBAPL_ShowTrialNag
Section titled “VBAPL_ShowTrialNag”Displays the trial nag screen that reminds the user to activate.
Public Function VBAPL_ShowTrialNag(Optional ForceDisplay As Boolean = False) As Long| Parameter | Type | Default | Description |
|---|---|---|---|
ForceDisplay | Boolean | False | When True, shows the dialog even if not in trial mode. |
Return codes:
| Value | Meaning |
|---|---|
0 | User chose to continue in trial mode |
1 | User wants to activate (call VBAPL_ShowActivation next) |
2 | User clicked the purchase link (URL opened in browser) |
-1 | Error or not initialized |
-2 | Not in trial mode (and ForceDisplay = False) |
-3 | Silent mode is enabled (nag screen disabled in settings) |
Example:
If VBAPL_IsTrialMode() Then Dim nagResult As Long nagResult = VBAPL_ShowTrialNag()
If nagResult = 1 Then ' User wants to activate VBAPL_ShowActivation End IfEnd IfDeactivation
Section titled “Deactivation”VBAPL_ShowDeactivation
Section titled “VBAPL_ShowDeactivation”Displays the deactivation dialog, allowing the user to deactivate their license (e.g., before transferring to a new computer).
Public Function VBAPL_ShowDeactivation() As LongReturn codes:
| Value | Meaning |
|---|---|
0 | License deactivated successfully |
1 | User cancelled |
-1 | DLL not initialized |
-2 | No license to deactivate |
-3 | License already deactivated |
-4 | Deactivation not allowed for this project |
Example:
Dim result As Longresult = VBAPL_ShowDeactivation()If result = 0 Then MsgBox "License deactivated. You can now activate on another computer.", vbInformationEnd IfVBAPL_Deactivate
Section titled “VBAPL_Deactivate”Deactivates the license programmatically without showing a dialog. Returns a deactivation certificate that the user can send to the vendor as proof of deactivation.
Public Function VBAPL_Deactivate(ByRef ResultCode As Long) As String| Parameter | Type | Description |
|---|---|---|
ResultCode | Long (ByRef) | Receives the result code: 0 = success. |
Returns: A deactivation certificate string, or an empty string on failure.
Example:
Dim resultCode As LongDim certificate As Stringcertificate = VBAPL_Deactivate(resultCode)
If resultCode = 0 Then ' Save or display the certificate MsgBox "Deactivation certificate:" & vbCrLf & certificate, vbInformationEnd IfVBAPL_GetDeactivationStatus
Section titled “VBAPL_GetDeactivationStatus”Returns the current deactivation status without performing any action.
Public Function VBAPL_GetDeactivationStatus() As LongReturn codes:
| Value | Meaning |
|---|---|
0 | Deactivation allowed (license is active) |
1 | Deactivation allowed (no license stored) |
2 | Deactivation not allowed for this application |
3 | License already deactivated or blacklisted |
-1 | DLL not initialized |
VBAPL_ShowEULA
Section titled “VBAPL_ShowEULA”Displays the End User License Agreement dialog.
Public Function VBAPL_ShowEULA(Optional ForceDisplay As Boolean = False) As Long| Parameter | Type | Default | Description |
|---|---|---|---|
ForceDisplay | Boolean | False | When True, shows the EULA even if already accepted. |
Return codes:
| Value | Meaning |
|---|---|
1 | EULA accepted |
0 | EULA declined |
-1 | Error |
-2 | EULA not configured for this project |
Example:
' Show EULA on first launchDim eulaResult As LongeulaResult = VBAPL_ShowEULA()
If eulaResult = 0 Then MsgBox "You must accept the license agreement to use this application.", vbCritical ThisWorkbook.Close SaveChanges:=FalseEnd IfVBAPL_IsEulaAccepted
Section titled “VBAPL_IsEulaAccepted”Checks whether the EULA has been accepted without displaying the dialog.
Public Function VBAPL_IsEulaAccepted() As BooleanReturns: True if the EULA has been accepted (or if no EULA is configured). False otherwise.
VBAPL_GetEulaAcceptanceDate
Section titled “VBAPL_GetEulaAcceptanceDate”Returns the date and time when the EULA was accepted.
Public Function VBAPL_GetEulaAcceptanceDate() As StringReturns: A date/time string in YYYY-MM-DD HH:NN:SS format, or an empty string if the EULA has not been accepted.
Example:
If VBAPL_IsEulaAccepted() Then Debug.Print "EULA accepted on: " & VBAPL_GetEulaAcceptanceDate()End IfProject Properties
Section titled “Project Properties”VBAPL_GetProperty
Section titled “VBAPL_GetProperty”Returns a project property value that was set in VBA Padlock Studio.
Public Function VBAPL_GetProperty(PropName As String, Optional DefaultValue As Variant = "") As Variant| Parameter | Type | Default | Description |
|---|---|---|---|
PropName | String | — | Property name (case-insensitive). |
DefaultValue | Variant | "" | Value returned if the property is not found. |
Available properties:
| Property Name | Description |
|---|---|
AppTitle | Application title |
AppVersion | Version number |
AppCompany | Company name |
AppCopyright | Copyright notice |
AppDescription | Application description |
RegisteredName | Licensee name (same as VBAPL_GetRegisteredName) |
LicenseKey | The stored license key string |
Example:
Dim appTitle As StringappTitle = VBAPL_GetProperty("AppTitle", "My Application")
Dim version As Stringversion = VBAPL_GetProperty("AppVersion", "1.0.0.0")
MsgBox appTitle & " v" & version, vbInformationOnline Validation
Section titled “Online Validation”VBAPL_ValidateOnline
Section titled “VBAPL_ValidateOnline”Performs an online license validation against the activation server. This checks that the user’s license is still valid and has not been revoked.
Public Function VBAPL_ValidateOnline(Optional Silent As Boolean = True) As Long| Parameter | Type | Default | Description |
|---|---|---|---|
Silent | Boolean | True | When True, no UI is shown on failure. When False, error dialogs are displayed. |
Return codes:
| Value | Meaning |
|---|---|
1 | Validation successful |
0 | Validation failed (license revoked or invalid) |
-1 | DLL not initialized |
-2 | Online validation not configured |
-3 | No stored license to validate |
-4 | Network error (no internet connection) |
-5 | Server error |
-6 | Security validation failed |
Example:
Dim result As Longresult = VBAPL_ValidateOnline(False) ' Show errors to the user
Select Case result Case 1 ' License is valid Case 0 MsgBox "Your license has been revoked.", vbCritical Case -4 MsgBox "Could not connect to validation server.", vbExclamationEnd SelectVBAPL_IsValidationRequired
Section titled “VBAPL_IsValidationRequired”Checks whether an online validation is due now, based on the configured validation policy.
Public Function VBAPL_IsValidationRequired() As LongReturn codes:
| Value | Meaning |
|---|---|
1 | Validation is required |
0 | Validation not required (skipped based on policy) |
-1 | DLL not initialized |
-2 | Online validation not configured |
Example:
If VBAPL_IsValidationRequired() = 1 Then Dim result As Long result = VBAPL_ValidateOnline(False) If result <> 1 Then MsgBox "License validation failed.", vbCritical End IfEnd IfSecurity
Section titled “Security”VBAPL_VerifyDLLSignature
Section titled “VBAPL_VerifyDLLSignature”Verifies the Authenticode digital signature of the runtime DLL.
Public Function VBAPL_VerifyDLLSignature() As LongReturn codes:
| Value | Meaning |
|---|---|
0 | Valid signature (signed by G.D.G. Software) |
1 | DLL is not signed |
2 | Signature is invalid or corrupted |
3 | Signed by a different publisher (not G.D.G. Software) |
4 | Signing certificate has expired |
5 | System error during verification |
-1 | DLL not initialized |
Example:
Dim sigResult As LongsigResult = VBAPL_VerifyDLLSignature()
If sigResult <> 0 Then MsgBox "WARNING: DLL signature verification failed (code " & sigResult & ")." & vbCrLf & _ "The DLL may have been tampered with.", vbCritical ThisWorkbook.Close SaveChanges:=FalseEnd IfQuick Reference Table
Section titled “Quick Reference Table”| Function | Category | Returns |
|---|---|---|
VBAPL_Execute | Execution | Variant |
VBAPL_IsLicenseValid | License | Boolean |
VBAPL_HasStoredLicense | License | Boolean |
VBAPL_GetRegisteredName | License | String |
VBAPL_GetHardwareID | License | String |
VBAPL_ShowActivation | Activation | Long (code) |
VBAPL_IsTrialMode | Trial | Boolean |
VBAPL_GetTrialLimitLeft | Trial | Long |
VBAPL_ShowTrialNag | Trial | Long (code) |
VBAPL_ShowDeactivation | Deactivation | Long (code) |
VBAPL_Deactivate | Deactivation | String |
VBAPL_GetDeactivationStatus | Deactivation | Long (code) |
VBAPL_ShowEULA | EULA | Long (code) |
VBAPL_IsEulaAccepted | EULA | Boolean |
VBAPL_GetEulaAcceptanceDate | EULA | String |
VBAPL_ValidateOnline | Online Validation | Long (code) |
VBAPL_IsValidationRequired | Online Validation | Long (code) |
VBAPL_GetProperty | Properties | Variant |
VBAPL_VerifyDLLSignature | Security | Long (code) |
Typical Initialization Flow
Section titled “Typical Initialization Flow”A common pattern for initializing your protected application:
Public Sub Workbook_Open() ' 1. Show EULA on first launch If VBAPL_ShowEULA() = 0 Then ThisWorkbook.Close SaveChanges:=False Exit Sub End If
' 2. Check license If Not VBAPL_IsLicenseValid() Then If VBAPL_IsTrialMode() Then ' Show trial nag screen Dim nagResult As Long nagResult = VBAPL_ShowTrialNag() If nagResult = 1 Then VBAPL_ShowActivation End If Else ' No trial — require activation If VBAPL_ShowActivation() <> 1 Then MsgBox "Activation required.", vbCritical ThisWorkbook.Close SaveChanges:=False Exit Sub End If End If End If
' 3. Run the main application logic VBAPL_Execute "Main|Initialize"End SubSee Also
Section titled “See Also”- DLL Export Reference — Low-level DLL function signatures for advanced
Declareusage - License Return Codes — Complete list of all error and return codes
- Script Functions Reference — Functions available inside compiled scripts
- Protect an Excel Workbook — Step-by-step tutorial using the VBA Bridge