Link to home
Start Free TrialLog in
Avatar of Mark Drelinger
Mark DrelingerFlag for United States of America

asked on

add a password to open excel after 60 days

I have an excel document that I want to require a password to open after 30 days.
I don't want to kill or delete the document, just require a password.
Avatar of Scott C
Scott C
Flag of United States of America image

So you don't want the document to be able to be opened UNTIL 30/60 days have passed and then only with a password?

Possibly with the workbook open event...

Private Sub Workbook_Open()
If Now > 42298 Then
    ThisWorkbook.Protect Password:="SpongeBob"
End If
End Sub
So no password until 30 days after creation?

You would have to have the date the workbook was made written in the sheet somewhere. A macro that runs when the file is opened could then check if the current date is 30 days after the creation date, set a password and force the file closed. However that solution has some downsides, such as requiring that somebody try to open the file before the passwords get set.

The most secure way would be if you could password protect the files without opening them. But I don't think that would be an Excel solution, it would have to happen at the windows level.
ASKER CERTIFIED SOLUTION
Avatar of Scott C
Scott C
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark Drelinger

ASKER

To clarify.  I would set the expiration date in code.
I'd like a password added to the file on a particular date.
wow, that's perfect.. and small code...
Thanks much.
Mark
Glad I could help.
Are links to other Forums allowed, I was told not! Apparently I am not even allowed to link to my own site.
I've never had a problem before.  I simply referenced what I found to not run into copyright issues.