Setting up Trial Versions

Hermannjt

New member
I am approaching the Beta Test phase for an app I have been working on. The production version will have a "No Refund after 15 days, or Product Activation, which ever comes first" policy. Is it possible, like most commercial software applications, to have a pop-up (HTML or MsgBox during the workbook open process) that queries the user whether to continue the Trail Period or proceed with activation? If they choose the "Register" option it would then initiate the Get System ID process for off-line registration.

How might one go about implementing this?
 
Last edited:
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.
 
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.
Thank you very much. I have been going blind researching this issue.

How much of this functionality be tested during the "Pre-Compile" development phase?
 
@gdgsupport

I need to re-phrase my previous question. My question about testing your VBA Macros/Functions suggestions was not about using the free version of XLS Padlock. The question is about testing in the original Workbook prior to using XLS PadLock to compile the workbook.

For example, running the "IsTrial" Function always returns "False"!

'Create a function that checks if the application is running as a trial.
Public Function IsTrial() As Boolean
Dim XLSPadlock As Object
On Error GoTo Err

Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
IsTrial = XLSPadlock.PLEvalVar("IsTrial") <--- what is the origin of "IsTrial"?
Debug.Print " Trial Mode = '" & IsTrial & "'"
Exit Function
Err:
IsTrial = False
End Function
'Return values:
' TRUE - Trial version
' FALSE - Activated version
 
Thanks for the clarification.

The IsTrial() function is intended to work only when the workbook is running inside the compiled XLS Padlock application, not while testing the original workbook directly in Excel.

So in your original workbook, this line:

Code:
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

does not provide the compiled application's runtime trial status. If the COM object is unavailable or does not return the expected value in that context, your function falls back to the error handler and returns False. Which is expected.

Regarding your question about the origin of "IsTrial": it is not a VBA variable defined in your workbook. It is an internal XLS Padlock runtime variable exposed through:

Code:
XLSPadlock.PLEvalVar("IsTrial")

In other words, PLEvalVar() queries a variable provided by the XLS Padlock runtime environment.

There is also an important detail: even in the compiled application, IsTrial returns True only when the activation key is configured as a trial key with the nag screen option enabled. Otherwise it will return False.

So the expected behavior is:

  • In the original workbook before compilation, IsTrial() should not be used for testing trial mode.
  • In the compiled EXE, IsTrial() can be used.
  • It returns True only for an actual trial activation state.

If needed, a better first check is to verify whether the code is running inside a protected XLS Padlock application at all.

Best regards
 
Thanks for the clarification.

The IsTrial() function is intended to work only when the workbook is running inside the compiled XLS Padlock application, not while testing the original workbook directly in Excel.

So in your original workbook, this line:

Code:
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

does not provide the compiled application's runtime trial status. If the COM object is unavailable or does not return the expected value in that context, your function falls back to the error handler and returns False. Which is expected.

Regarding your question about the origin of "IsTrial": it is not a VBA variable defined in your workbook. It is an internal XLS Padlock runtime variable exposed through:

Code:
XLSPadlock.PLEvalVar("IsTrial")

In other words, PLEvalVar() queries a variable provided by the XLS Padlock runtime environment.

There is also an important detail: even in the compiled application, IsTrial returns True only when the activation key is configured as a trial key with the nag screen option enabled. Otherwise it will return False.

So the expected behavior is:

  • In the original workbook before compilation, IsTrial() should not be used for testing trial mode.
  • In the compiled EXE, IsTrial() can be used.
  • It returns True only for an actual trial activation state.

If needed, a better first check is to verify whether the code is running inside a protected XLS Padlock application at all.

Best regards

Thanks for the clarification.

The IsTrial() function is intended to work only when the workbook is running inside the compiled XLS Padlock application, not while testing the original workbook directly in Excel.

So in your original workbook, this line:

Code:
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

does not provide the compiled application's runtime trial status. If the COM object is unavailable or does not return the expected value in that context, your function falls back to the error handler and returns False. Which is expected.

Regarding your question about the origin of "IsTrial": it is not a VBA variable defined in your workbook. It is an internal XLS Padlock runtime variable exposed through:

Code:
XLSPadlock.PLEvalVar("IsTrial")

In other words, PLEvalVar() queries a variable provided by the XLS Padlock runtime environment.

There is also an important detail: even in the compiled application, IsTrial returns True only when the activation key is configured as a trial key with the nag screen option enabled. Otherwise it will return False.

So the expected behavior is:

  • In the original workbook before compilation, IsTrial() should not be used for testing trial mode.
  • In the compiled EXE, IsTrial() can be used.
  • It returns True only for an actual trial activation state.

If needed, a better first check is to verify whether the code is running inside a protected XLS Padlock application at all.

Best regards
I had hoped that there was a way of operate the compiled *.exe in Trial Mode without a key, using a periodic "Nag" during the first 15 days without the key requirement, thus eliminating a "Dual Key" scenario. Does the XLS PadLock "Activation Kit" provide that possibility? If not, I suppose I could still use the Registration Form I developed prior to my learning about your product. The first time the user opens the workbook it records the "Start Date" and initiates the 30-day trial period. The form also requires certain information that customizes the workbook for their use.
 
XLS Padlock’s built-in trial mode is based on activation keys. In practice, this means the standard trial workflow requires the user to activate the compiled EXE with a trial key first. The nag screen and the trial state are both linked to that trial-key configuration.
You could generate a trial key once and you give it to all of end users who want to try your EXE file. It must NOT be hardware-locked in that specific case.

As for the Activation Kit, it is designed to automate the delivery of activation keys from your server. It still works within the activation-key model and does not provide a separate mode that allows the EXE to run for a limited number of days without any key at all.

Your custom registration form therefore remains a valid solution, that approach can work well alongside XLS Padlock, which can still be used to protect the workbook itself, secure the VBA project, and compile sensitive code, while your own form handles the trial and registration logic.

One additional point: if you rely on your own time-limited trial system, it may also be helpful to automatically close the workbook after a fixed session duration. Otherwise, a user could potentially leave the workbook open indefinitely and bypass part of the intended limitation...

Hope this helps!
 
XLS Padlock’s built-in trial mode is based on activation keys. In practice, this means the standard trial workflow requires the user to activate the compiled EXE with a trial key first. The nag screen and the trial state are both linked to that trial-key configuration.
You could generate a trial key once and you give it to all of end users who want to try your EXE file. It must NOT be hardware-locked in that specific case.

As for the Activation Kit, it is designed to automate the delivery of activation keys from your server. It still works within the activation-key model and does not provide a separate mode that allows the EXE to run for a limited number of days without any key at all.

Your custom registration form therefore remains a valid solution, that approach can work well alongside XLS Padlock, which can still be used to protect the workbook itself, secure the VBA project, and compile sensitive code, while your own form handles the trial and registration logic.

One additional point: if you rely on your own time-limited trial system, it may also be helpful to automatically close the workbook after a fixed session duration. Otherwise, a user could potentially leave the workbook open indefinitely and bypass part of the intended limitation...

Hope this helps!
Thanks again. I am trying to get everything set up to work with the Woo Integration Kit and I have a couple of questions which I will ask one at a time. The XLS PadLock plugin uses 'Trial Days' and 'Display the nag screen' to let the app know it is a trial version. Which of the two actually determines apps pre-activation state? The Integration Kit (workbooks.json) uses ' "keymaxdays": ?,' and ' "shownagscreen": 1'. Does 'Trial Days' = "keymaxdays" equivalencies?
 
Short answer:

  • &quot;Trial Days&quot; in the XLS Padlock desktop UI and keymaxdays in the Woo Integration Kit&#39;s workbooks.json are the same field. They both set the maximum number of days the key remains valid from the date of first activation.
  • &quot;Display the nag screen&quot; in the desktop UI and shownagscreen in workbooks.json are also the same field. They both flip the key between &quot;registered&quot; mode and &quot;trial&quot; mode.
Which of the two actually determines the app&#39;s pre-activation / trial state?

It&#39;s shownagscreen (= &quot;Display the nag screen&quot;). That flag is what makes the generated key a trial key, and it is what makes PLEvalVar("IsTrial") return True at runtime. keymaxdays / &quot;Trial Days&quot; only controls how long the key is valid before it expires — it does not, on its own, mark the key as &quot;trial&quot;. You can perfectly well have:

  • shownagscreen = 1 and no keymaxdays → a trial key with no time limit (nag-only)
  • shownagscreen = 0 and keymaxdays = 365 → a registered annual key that expires after 365 days (no nag, IsTrial returns False)
  • shownagscreen = 1 and keymaxdays = 15 → the classic 15-day trial (nag + time limit), which is what your policy describes
So for your &quot;No Refund after 15 days or Product Activation, whichever comes first&quot; setup, the Integration Kit entry for the trial product should have both shownagscreen = 1 and keymaxdays = 15. The nag flag is what IsTrial() keys off in VBA; keymaxdays is what actually stops the EXE from running after day 15.

One small but important detail that catches people out with the Integration Kit: a trial key generated this way must not be hardware-locked, otherwise each trial key can only be activated on a single machine and you&#39;d need to issue a new one per user. For the &quot;give everyone the same trial key&quot; pattern, keep the hardware-locking option off on that specific product in the kit. Only the paid (activation) product should be hardware-locked.
 
Short answer:

  • &quot;Trial Days&quot; in the XLS Padlock desktop UI and keymaxdays in the Woo Integration Kit&#39;s workbooks.json are the same field. They both set the maximum number of days the key remains valid from the date of first activation.
  • &quot;Display the nag screen&quot; in the desktop UI and shownagscreen in workbooks.json are also the same field. They both flip the key between &quot;registered&quot; mode and &quot;trial&quot; mode.
Which of the two actually determines the app&#39;s pre-activation / trial state?

It&#39;s shownagscreen (= &quot;Display the nag screen&quot;). That flag is what makes the generated key a trial key, and it is what makes PLEvalVar("IsTrial") return True at runtime. keymaxdays / &quot;Trial Days&quot; only controls how long the key is valid before it expires — it does not, on its own, mark the key as &quot;trial&quot;. You can perfectly well have:

  • shownagscreen = 1 and no keymaxdays → a trial key with no time limit (nag-only)
  • shownagscreen = 0 and keymaxdays = 365 → a registered annual key that expires after 365 days (no nag, IsTrial returns False)
  • shownagscreen = 1 and keymaxdays = 15 → the classic 15-day trial (nag + time limit), which is what your policy describes
So for your &quot;No Refund after 15 days or Product Activation, whichever comes first&quot; setup, the Integration Kit entry for the trial product should have both shownagscreen = 1 and keymaxdays = 15. The nag flag is what IsTrial() keys off in VBA; keymaxdays is what actually stops the EXE from running after day 15.

One small but important detail that catches people out with the Integration Kit: a trial key generated this way must not be hardware-locked, otherwise each trial key can only be activated on a single machine and you&#39;d need to issue a new one per user. For the &quot;give everyone the same trial key&quot; pattern, keep the hardware-locking option off on that specific product in the kit. Only the paid (activation) product should be hardware-locked.
Thanks. This brings me to question 2. Getting the Integration Kit setup to communicate with WP WooCommerce was the easy part. I have set up the initial Beta product in WP with the necessary IDs. How can I get WooCommerce to generate the necessary keys/Tokens? neither the Kit Documentation nor the Woo Documentation provide insight into this. I presume there is some form of wp-activation.php that sets up that information exchange. Correct?
 
Back
Top