Skip to content

Retrieve Remaining Trial Days with VBA

This VBA function allows you to programmatically retrieve the number of remaining days or executions for a trial workbook. It also works for registered keys that have an expiration date or a limited number of runs.

👉 Insert the following function into a VBA module:

Public Function ReadTrialState()
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
ReadTrialState = XLSPadlock.PLEvalVar("TrialState")
Exit Function
Err:
ReadTrialState = ""
End Function

You can then call the function:

Sub Test_Trial()
rdays = ReadTrialState()
Worksheets("Sheet1").Range("A1").Value = rdays
End Sub

👉 See Also: How to create Trial workbooks