Yes — this is absolutely possible and it’s a very common licensing pattern for XLS Padlock applications.
The concept is simple: the application starts normally, then VBA checks whether the app is running in trial mode. If it is, a dialog prompts the user to either continue the trial or activate the product.
XLS Padlock provides an API that lets you detect whether the workbook is running in trial mode or activated mode.
Below is a typical implementation.
1. Detect Trial Mode
Create a function that checks if the application is running as a trial.
Code:
Public Function IsTrial() As Boolean
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
IsTrial = XLSPadlock.PLEvalVar("IsTrial")
Exit Function
Err:
IsTrial = False
End Function
Return values:
- TRUE → Trial version
- FALSE → Activated version
2. Run the Check at Startup
Add this to
ThisWorkbook:
Code:
Private Sub Workbook_Open()
If IsTrial() Then
Call ShowTrialPrompt
End If
End Sub
This ensures the prompt appears every time the workbook opens during the trial period.
3. Create the Trial / Activation Prompt
Option A — Simple MsgBox
Code:
Sub ShowTrialPrompt()
Dim result As VbMsgBoxResult
result = MsgBox( _
"You are currently running the trial version." & vbCrLf & vbCrLf & _
"Select YES to activate your license." & vbCrLf & _
"Select NO to continue the trial.", _
vbYesNo + vbQuestion, _
"Trial Version")
If result = vbYes Then
Call StartActivation
End If
End Sub
Option B — Custom UserForm (Recommended)
Most commercial apps use a UserForm dialog, because it allows more options:
Code:
[ Continue Trial ]
[ Register Product ]
[ Purchase License ]
You can also display the number of remaining trial days.
4. Launch the Activation Process
When the user clicks Register, launch the XLS Padlock activation dialog.
Code:
Sub StartActivation()
Dim XLSPadlock As Object
Set XLSPadlock = Application.COMAddIns("GXLS.GXLSPLock").Object
'Show activation dialog
XLSPadlock.SetOption "4", "1"
End Sub
This opens the built-in XLS Padlock activation window, where the user can obtain their System ID for offline activation.
The user sends you the System ID and you generate a hardware-locked activation key using the Key Generator.
5. Optional Improvements
Display remaining trial days
Code:
RemainingDays = XLSPadlock.PLEvalVar("TrialDaysLeft")
Example:
Code:
You have 7 days remaining in your trial.
Add a purchase button
Code:
ThisWorkbook.FollowHyperlink "https://yourwebsite.com/buy"
BTW You do not need to build the activation system yourself.
XLS Padlock already provides:
- Activation key system
- Hardware-locked licenses
- System ID generation
- Activation dialog
Your VBA code only controls when the prompt appears and what options the user sees.