Prevent Users Manipulating Time Out on Excel

sabbuck

New Member
Joined
Aug 21, 2017
Messages
21
Hi All,

I have a form on excel which is being used on a trial basis. Once the trial is up a message box appears to inform the user their trial has expired. If the expiry date in the code is 31/08/17 it should expire as today's date is 15/09/17...which it does. But I've realized if I manually change the date on my computer to say 29/08/17 then the code doesn't recognize today's actual date, it will only recognize the date I have set my computer to. Is there a way to prevent this? I don't want users being able to access this form after their trial has expired. The code I'm currently using is:

Code:
'Dim Edate As DateEdate = Format("30/09/2017", "DD/MM/YYYY")
If Date > Edate Then
MsgBox ("CURMIS Investment Register template was valid up to " & Format(Edate, "dd-mmm-yyyy") & " and will close.") & vbNewLine & " " & vbNewLine & "Please Contact Michael O'Grady & Co. for further use of this tool."
ActiveWorkbook.Close savechanges:=False'
 

pjmorris

Well-known Member
Joined
Aug 2, 2012
Messages
1,655
Office Version
2016
Platform
Windows
hi Sabbuck,

Apologies for not providing a better steer, but the steps I'd take would be to access a remote time server to retrieve the time - provided the computer is connected to the internet I would expect it to work. I found more detail here: http://www.myengineeringworld.net/2013/09/retrieve-time-from-internet-server-vba.html but haven't had a chance to check it.

The alternative is to recognise that people are basically lazy and won't think to change the computer clock until after the event. Thus you could use the normal NOW() function and then use xlVeryHidden to hide the sheet in a way that normal users can't unhide. The code for this would be something like:

Code:
worksheets("Trial Sheet").visible=xlVeryHidden
you can unhide the sheet either programmatically by setting the visible property to 'True' or via the sheet properties in the VBE.

Final thought - make sure your code is password protected.

Hope this helps.

Regards

Peter
 

Forum statistics

Threads
1,086,125
Messages
5,387,986
Members
402,094
Latest member
Bloody69

Some videos you may like

This Week's Hot Topics

Top