I have a sheet set up to expire after a certain date in Excel. The biggest flaw in this is someone changing the system date back. Is there a way to make sure the system date is current before the workbook will open? Thanks for any help you can offer.
Code:
Private Sub Workbook_Open()
'ThisWorkbook code! double click ThisWorkbook and enter this code
Dim Message$, Title$, Default$, myUnLock$, myTest$
Sheet1.Visible = True
myTest = Sheet1.Range("IV1").Value
If (myPW = "gabriel" And myTest = myPW) Then End
myUnLock = "gabriel"
Sheet1.Unprotect Password:=myUnLock
If (Date > #2/28/2007# And _
Sheet1.Visible <> xlVeryHidden And _
myUnLock <> myTest) Then
MsgBox "You need a password to continue"
Sheet1.Protect Password:=myUnLock
Sheet1.Visible = xlVeryHidden
End If
If (Date > #2/28/2007# And _
Sheet1.Visible = xlVeryHidden) Then
Message = "Enter your Un-Lock code below:" ' Set prompt.
Title = "Unlock Sheet!" ' Set title.
Default = "" ' Set default.
myPW = InputBox(Message, Title, Default)
End If
If myPW = myUnLock Then
Sheet1.Unprotect Password:=myUnLock
Sheet1.Visible = True
'Optional permanent UnLock by password:
'comment the line below to lock each time opened after date!
Sheet1.Range("IV1").Value = myPW
Sheet1.Select
End If
End Sub
Sub mySheets()
Sheet1.Visible = True
Sheet1.Select
Sheet1.Unprotect Password:="gabriel"
'Worksheets("Sheet1").Protect Password:="gabriel"
End Sub
Write the system date to the registry, but disguised or encrypted so the user cant find it and change it, on the first run
of the program. Then each time it is run you chech against the system date and compare the registry date. If the
system date is before the registry date then they changed it back, etc.
You could have it check out to the internet to a time server and compare the actual date to the system date.
You could also check in MartinLiss' signature for "A Program Registration Scheme" demo code project.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Write the system date to the registry, but disguised or encrypted so the user cant find it and change it, on the first run
of the program. Then each time it is run you chech against the system date and compare the registry date. If the
system date is before the registry date then they changed it back, etc.
This sounds the easiest. Can you point me in the right direction on how to do this?
You would need to use the GetSetting and SaveSetting functions. They only read/write to the VB and VBA Program Settings
key but in there you can name it however you want. If you want to read/write to other areas in the registry you may
come accross issues where the user does not have registry permissions.
Yeah that would be a problem. I am sure that some of the people who will use my workbook won't have administrator rights. People tend to panic when you mess with the registry.
"You could have it check out to the internet to a time server and compare the actual date to the system date."
I would love to use this, but too many people have web pages blocked. The simplest pages i.e. google are blocked with a program called we-block.
No, I was referring to the other areas of the registry. The VB and VBA program and settings key does not need
special prividgels because of the way its designed for programs to write to by default using the get and save settings.
Edit: There is also somewhere on the forums a 30 day trial code if I remember correctly.
Last edited by RobDog888; Apr 24th, 2005 at 08:26 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Could you give me an example of how these sections might be filled in, or is the code the way it is suppose to be already? ("AppName", "Section", "InstallDate", "Default") I would really like to try this.