Hello,
I found this expiration code and wanted to see if there is a way that when the time lapses that an update file can be sent to the User and reset the date in this code to the desired number of days in that update.
This code shows a 30 day period and then the Excel file is stopped.
Is there a way that a new Module can be loaded into the workbook and overwrite this Module and that would contain the new expiration date?
' Update this variable to set your own expiration period by number of days
Private Const NUM_DAYS_UNTIL_EXPIRATION = 30
Private Sub Expiration_Date()
Dim ExpDate As String
On Error Resume Next
ExpDate = Mid(ThisWorkbook.Names("ExpDate").Value, 2)
If Err.Number <> 0 Then
' Name doesn't exist.
' Calculate new expiration date
ExpDate = CStr(DateSerial(Year(Now), _
Month(Now), Day(Now) + NUM_DAYS_UNTIL_EXPIRATION))
' Create a named range and store the date in the named range
ThisWorkbook.Names.Add Name:="ExpDate", _
RefersTo:=Format(ExpDate, "short date"), _
Visible:=False
' Save the file
ThisWorkbook.Save
End If
' Comapare today and expriation date
If CDate(Now) > CDate(ExpDate) Then
' Expired
MsgBox "Your StatsSystems subscription has EXPIRED, Please contact sales@statssystems.com to Re-Subscribe.", vbOKOnly
ThisWorkbook.Close savechanges:=False
End If
End Sub
Your thoughts?
Thanks,
John
Bookmarks