I want to write an excel macro that will lock the

ittech
08-12-2001, 07:14 PM
file after a certain date.

ie if date is greater than mm/dd/yyyy
then save with a password and close the file.

can someone help?

BlueRaja
08-15-2001, 09:02 AM
Hi,

You can protect,save & close your file with

ActiveWorkbook.Protect Password:="a", Structure:=True, Windows:=True
Application.SaveWorkspace "C:\my documents\x.wks"
Application.Quit

I do not know the best way of setting a 'shutdown-date' . You could try storing a future date on a hidden sheet and then testing this value whenever the sheet was opened. You could use the Workbook_Open() event and the Now() command to test if the sheet can be opened...

Sub Workbook_Open()
if hiddenval >= now() then
.....display closed msg and shutdown
else
.....do nothing
end if
end sub

Hope this helps!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum