Excel Macro to password protect

15 pts.
Tags:
Excel macros
Microsoft Excel
Microsoft Excel password protection
I have this spread sheet that I want to be able to protect from distrubution when given to one person. Is there a way of writing in a macro that will ask for a new password that is in a hidden list at the end of say 30 days and if not entered in the program will not be usable? I hope that my question is clear enough for an answer. Thanks
ASKED: February 9, 2009  1:58 AM
UPDATED: July 31, 2011  3:13 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

right-click the Excel LOGO near the file menu, select View Code, paste this in:

Private Sub Workbook_Open()
If GetSetting(“open”, “open”, “Count”, 0) * 1 = 30 Then
Msgbox “Expired!”
ThisWorkbook.Close False
End If
SaveSetting “open”, “open”, “Count”, GetSetting(“open”, “open”, “Count”, 0) * 1 + 1
End Sub

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Smarbada
    I understand what this code is doing and how it works but I got it to work once and then I entered it again using the number 3 rather than 30 to test it and now it doesn't run. Hum maybe something I did. But thanks so much for your time on this.
    15 pointsBadges:
    report
  • JP2112
    I can just click "No" to the "Allow Macros" dialog box when opening your workbook. That would stop the macro from running.
    475 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following