Set Expiry date for a workbook using vba code

K

Kannan

Hello there,

Could anyone please give me the vba code for setting expiry date for
an excel workbook?
 
P

Paul B

Kannan,
Here is one way, but all you would have to do is open the workbook with
macros disabled, you could also hide the sheets, but be aware that ANYTHING
you do to attempt this can be defeated if somebody wants to get in the
workbook, excel is not very secure



Private Sub Workbook_Open()

If Date > #9/15/04# Then

ThisWorkbook.Close

End If

End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
 
H

Hari

Hi Kannan,

You can do this even if the macros are not enabled.

In the code within the workbook module have a workbook_close event in which
you hide all sheets except one sheet. This one sheet may be a useless/dummy
one.

Then in the workbook_open event use the if statement provided by Paul B
If the If test for date is true then unhide all sheets and hide the dummy
sheet.
Exit out of the If statement.

This way only if the macros are enabled and only if the date is within the
desired/target one would be able to work on the file

AFAIK expiry date checks might be useless because they can be breached by
changing the computer time

Regards,
Hari
India
 

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