Skip to content

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.

All VBA Bridge functions are prefixed with VBAPL_. Internally, each function:

  1. Ensures the DLL is loaded and initialized (once per session)
  2. Calls the corresponding native DLL export (32-bit or 64-bit, selected automatically)
  3. Returns the result to your VBA code

Executes a compiled function inside the protected DLL.

Public Function VBAPL_Execute(ID As Variant, ParamArray Args() As Variant) As Variant
ParameterTypeDescription
IDVariantFunction 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.
ArgsParamArrayArguments 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 parameters
Dim result As Variant
result = VBAPL_Execute("Main|Initialize")
' Call a function with parameters
Dim total As Variant
total = VBAPL_Execute("Main|CalculatePrice", quantity, unitPrice, taxRate)
' Call a function without specifying the module
Dim msg As Variant
msg = VBAPL_Execute("GetWelcomeMessage", userName)
' Call a function with many parameters (no limit)
Dim report As Variant
report = VBAPL_Execute("Reports|Generate", title, startDate, endDate, format, outputPath, includeCharts)

Checks whether the current license is valid.

Public Function VBAPL_IsLicenseValid() As Boolean

Returns: 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_ShowActivation
End If

Checks whether a license key is stored on this computer.

Public Function VBAPL_HasStoredLicense() As Boolean

Returns: 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.", vbExclamation
End If

Returns the registered user name (licensee name) from the stored license.

Public Function VBAPL_GetRegisteredName() As String

Returns: The registered name string, or an empty string if no license is stored.

Example:

Dim licensee As String
licensee = VBAPL_GetRegisteredName()
If licensee <> "" Then
StatusBar.Text = "Licensed to " & licensee
End If

Returns the Hardware ID for the current computer. This ID is unique per machine and per project.

Public Function VBAPL_GetHardwareID() As String

Returns: A formatted Hardware ID string (e.g., XXXXX-XXXXX-XXXXX), or an empty string on failure.

Example:

Dim hwid As String
hwid = VBAPL_GetHardwareID()
MsgBox "Your Hardware ID is: " & hwid & vbCrLf & _
"Send this to your vendor to receive a license key.", vbInformation

Displays the activation dialog where the user can enter a license key.

Public Function VBAPL_ShowActivation(Optional ForceDisplay As Boolean = False) As Long
ParameterTypeDefaultDescription
ForceDisplayBooleanFalseWhen True, shows the dialog even if a license is already active.

Return codes:

ValueMeaning
1Activation successful
0User cancelled or activation failed
-1Error (DLL not initialized)
-2Activation is not configured for this project

Example:

Dim result As Long
result = 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 license
End Select

Checks whether the application is currently running in trial mode.

Public Function VBAPL_IsTrialMode() As Boolean

Returns: True if in trial mode. False if licensed or if trial mode is not configured.


Returns the remaining trial allowance (days, runs, or days until expiration, depending on configuration).

Public Function VBAPL_GetTrialLimitLeft() As Long

Return codes:

ValueMeaning
>= 0Remaining trial limit
-1DLL not initialized
-2Not in trial mode

Example:

If VBAPL_IsTrialMode() Then
Dim daysLeft As Long
daysLeft = VBAPL_GetTrialLimitLeft()
MsgBox "Trial mode: " & daysLeft & " days remaining.", vbInformation
End If

Displays the trial nag screen that reminds the user to activate.

Public Function VBAPL_ShowTrialNag(Optional ForceDisplay As Boolean = False) As Long
ParameterTypeDefaultDescription
ForceDisplayBooleanFalseWhen True, shows the dialog even if not in trial mode.

Return codes:

ValueMeaning
0User chose to continue in trial mode
1User wants to activate (call VBAPL_ShowActivation next)
2User clicked the purchase link (URL opened in browser)
-1Error or not initialized
-2Not in trial mode (and ForceDisplay = False)
-3Silent 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 If
End If

Displays the deactivation dialog, allowing the user to deactivate their license (e.g., before transferring to a new computer).

Public Function VBAPL_ShowDeactivation() As Long

Return codes:

ValueMeaning
0License deactivated successfully
1User cancelled
-1DLL not initialized
-2No license to deactivate
-3License already deactivated
-4Deactivation not allowed for this project

Example:

Dim result As Long
result = VBAPL_ShowDeactivation()
If result = 0 Then
MsgBox "License deactivated. You can now activate on another computer.", vbInformation
End If

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
ParameterTypeDescription
ResultCodeLong (ByRef)Receives the result code: 0 = success.

Returns: A deactivation certificate string, or an empty string on failure.

Example:

Dim resultCode As Long
Dim certificate As String
certificate = VBAPL_Deactivate(resultCode)
If resultCode = 0 Then
' Save or display the certificate
MsgBox "Deactivation certificate:" & vbCrLf & certificate, vbInformation
End If

Returns the current deactivation status without performing any action.

Public Function VBAPL_GetDeactivationStatus() As Long

Return codes:

ValueMeaning
0Deactivation allowed (license is active)
1Deactivation allowed (no license stored)
2Deactivation not allowed for this application
3License already deactivated or blacklisted
-1DLL not initialized

Displays the End User License Agreement dialog.

Public Function VBAPL_ShowEULA(Optional ForceDisplay As Boolean = False) As Long
ParameterTypeDefaultDescription
ForceDisplayBooleanFalseWhen True, shows the EULA even if already accepted.

Return codes:

ValueMeaning
1EULA accepted
0EULA declined
-1Error
-2EULA not configured for this project

Example:

' Show EULA on first launch
Dim eulaResult As Long
eulaResult = VBAPL_ShowEULA()
If eulaResult = 0 Then
MsgBox "You must accept the license agreement to use this application.", vbCritical
ThisWorkbook.Close SaveChanges:=False
End If

Checks whether the EULA has been accepted without displaying the dialog.

Public Function VBAPL_IsEulaAccepted() As Boolean

Returns: True if the EULA has been accepted (or if no EULA is configured). False otherwise.


Returns the date and time when the EULA was accepted.

Public Function VBAPL_GetEulaAcceptanceDate() As String

Returns: 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 If

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
ParameterTypeDefaultDescription
PropNameStringProperty name (case-insensitive).
DefaultValueVariant""Value returned if the property is not found.

Available properties:

Property NameDescription
AppTitleApplication title
AppVersionVersion number
AppCompanyCompany name
AppCopyrightCopyright notice
AppDescriptionApplication description
RegisteredNameLicensee name (same as VBAPL_GetRegisteredName)
LicenseKeyThe stored license key string

Example:

Dim appTitle As String
appTitle = VBAPL_GetProperty("AppTitle", "My Application")
Dim version As String
version = VBAPL_GetProperty("AppVersion", "1.0.0.0")
MsgBox appTitle & " v" & version, vbInformation

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
ParameterTypeDefaultDescription
SilentBooleanTrueWhen True, no UI is shown on failure. When False, error dialogs are displayed.

Return codes:

ValueMeaning
1Validation successful
0Validation failed (license revoked or invalid)
-1DLL not initialized
-2Online validation not configured
-3No stored license to validate
-4Network error (no internet connection)
-5Server error
-6Security validation failed

Example:

Dim result As Long
result = 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.", vbExclamation
End Select

Checks whether an online validation is due now, based on the configured validation policy.

Public Function VBAPL_IsValidationRequired() As Long

Return codes:

ValueMeaning
1Validation is required
0Validation not required (skipped based on policy)
-1DLL not initialized
-2Online 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 If
End If

Verifies the Authenticode digital signature of the runtime DLL.

Public Function VBAPL_VerifyDLLSignature() As Long

Return codes:

ValueMeaning
0Valid signature (signed by G.D.G. Software)
1DLL is not signed
2Signature is invalid or corrupted
3Signed by a different publisher (not G.D.G. Software)
4Signing certificate has expired
5System error during verification
-1DLL not initialized

Example:

Dim sigResult As Long
sigResult = 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:=False
End If

FunctionCategoryReturns
VBAPL_ExecuteExecutionVariant
VBAPL_IsLicenseValidLicenseBoolean
VBAPL_HasStoredLicenseLicenseBoolean
VBAPL_GetRegisteredNameLicenseString
VBAPL_GetHardwareIDLicenseString
VBAPL_ShowActivationActivationLong (code)
VBAPL_IsTrialModeTrialBoolean
VBAPL_GetTrialLimitLeftTrialLong
VBAPL_ShowTrialNagTrialLong (code)
VBAPL_ShowDeactivationDeactivationLong (code)
VBAPL_DeactivateDeactivationString
VBAPL_GetDeactivationStatusDeactivationLong (code)
VBAPL_ShowEULAEULALong (code)
VBAPL_IsEulaAcceptedEULABoolean
VBAPL_GetEulaAcceptanceDateEULAString
VBAPL_ValidateOnlineOnline ValidationLong (code)
VBAPL_IsValidationRequiredOnline ValidationLong (code)
VBAPL_GetPropertyPropertiesVariant
VBAPL_VerifyDLLSignatureSecurityLong (code)

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 Sub