trial period
"Jay" schreef in bericht
oups.com...
Hi
I have a workbook , i would like to give a Trial Period of 7 days ,
after that they should register inorder for them to continue using the
work book
can anyone provide macro code to do the same
i have no knowledge on vba coding , if you could explain how to do this
, i m greatful to y9ou
thank you in advance
Regards
Jay
Hi Jay,
U can use the Windows registry. Write the date first used, and check every
time the workbook is opened if the install date is less than 7 days ago or
more...
Private Sub Auto_Open()
Dim DateInst As Date
Dim DateUsed As Date
Dim wsh
Dim RegKey As String
Dim RegVal As String
Set wsh = CreateObject("WScript.Shell")
RegVal = "HKLM\SOFTWARE\YourName\InstallDate"
On Error Resume Next
RegKey = wsh.RegRead(RegVal)
If RegKey = Empty Then
DateInst = Format(Now(), "mm-dd-yyyy")
wsh.RegWrite RegVal, DateInst, "REG_SZ"
Else
If DateValue(Format(Now(), "mm-dd-yyyy")) - DateValue(RegKey) 7
Then
MsgBox "Expired! Please contact blah blah blah"
Application.DisplayAlerts = False
ThisWorkbook.Close
End If
End If
Set wsh = Nothing
End Sub
I used a simple sample, but you'd better use a sneaky registry key, just in
case of a smart user. Also protect the VBA project with a steady password.
Play around with the code above which you should put in a Module in Visual
Basic Editor, try to find out how it works and check your registry after
running, and if it's too tough, just ask.
|