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




Reply With Quote