Retrieve Expiration Date

I want to show the expiration date and number of days left in order to remind customers to renew their subscription before it is expired.
How can I use VBA to retrieve the expiration date from the activated licence?

It’s possible by reading the value of TrialState with the VBA helper:

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 

This function will return the number of remaining days in the trial (or number of runs).

Thanks for that, but it isn’t really what I’m after. What I’m looking for is the remaining days (or expiration date) of the official/registered compiled workbook (NOT TRIAL) which is activated by a key with expiration date.

Hope that I can get my point through.

Unfortunately, the function in the post above will only work for the trial state indeed. We’ll extend it to non-trial periods in the next XLS Padlock update.

Hi XLS Padlock, I would like to follow up this issue. How are you doing with this?

Normally, the following code will also work for non-trial if your key has an expiration date or number of runs. Try it:

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

It works now. Thank you.

1 Like

Can I have this Function in a cell showing the days remaining? Or does it only work calling it via Sub?
If it’s possible to have in a cell, how the formula would be? =ReadTrialState?

This is a generic function: you can read its value with a VBA proc and then store the value in a cell.
Yes, something like
rdays = ReadTrialState()
Worksheets(“Sheet1”).Range(“A1”).Value = rdays

These procedures do not work. The cell A1 always displays zero, no matter how many days are actually left.
Maybe there is an error in the macro?

Did you create an activation key with an expiration date or number of days? Does it have the “nag screen/trial” flag?

Yes, an activation key has been created for the trial version. When you start the file, a Display Nag Screen appears, where the number of remaining days is shown. But macros don’t work.