Lock workbook after elapsed time

H

Harry Archer

I need to lock a worksheet after 1 month has elapsed.

Any idea on how i can do this please?
 
J

J.E. McGimpsey

What do you mean by "lock"? If you mean protect the sheets and
workbooks, you can put this in your ThisWorkbook code module
(right-click on the workbook title bar and choose View Code):

Private Sub Workbook_Open()
Const PWORD As String = "drowssap"
Dim wkSht As Worksheet
If Date > DateSerial(2003, 12, 24) Then
ActiveWorkbook.Protect Password:=PWORD, _
Structure:=True, Windows:=False
For Each wkSht In Worksheets
wkSht.Protect Password:=PWORD
Next wkSht
End If
End Sub

Note that this can be bypassed if macros aren't enabled.

If you're looking for a way to prevent opening the file, or to
securely protect the workbook/worksheets, you can't. You can look in
the archives:

http://groups.google.com/advanced_group_search?q=group:*excel*

using "workbook expire" as keywords (no quotes), for suggestions,
but any method suggested can be easily overridden by someone who is
savvy enough to find these newsgroups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top