Timing Out a Workbook


Posted by Richard Locke on April 10, 2001 2:26 AM

Hi,

I am investigating putting an expiry date onto a spreadsheet - I appreciate that with VBA this will not be particularly secure, I'm just trying to add a deterrent.

To try an prevent a user just moving his system date, I would like to store a 'last used date'. Is there any way of updating this into the VBA module, rather than saving it onto a worksheet?

I would appreciate any help with this, or any advice on a better route for adding an expiry date.

Thanks in advance!

Richard

Posted by David Hawley on April 10, 2001 3:25 AM

Hi Richard

Not sure about preventing them from winding back the PC clock, but try this in the "ThisWorkbook" module of your Workbook. So long as you password protect the VBE it will work. But the user could still choose not to enable macros or deactivate Events.

Private Sub Workbook_Activate()
With Sheet1

.Visible = xlSheetVeryHidden
If .Cells(1, 1) = "" Then .Cells(1, 1) = Date + 30
If Date >= .Cells(1, 1) Then Me.Close SaveChanges:=False

End With
End Sub

Dave
OzGrid Business Applications



Posted by Richard Locke on April 10, 2001 3:44 AM

Dave,

Thanks for this.

I start up the workbook with the main worksheet veryhidden, so if they turn off macros/events they don't get anything they can use!

I intend to store two dates, a final expiry date, and a last used date. If the system date is ever earlier than the last used date, I can assume that the PC clock has been changed, and take appropriate action. Crude but it's the best I can come up with!

Thanks Again

Richard