password protect a worksheet

Billm

Board Regular
Joined
Mar 19, 2002
Messages
88
I want to make a spreadsheet available for say 30 days, then, after that time a messagebox appears notifying the user that the spreadsheet has expired ( and subsequently prevents them from opening it ) but then I still want to open it .. so can the messagebox then prompt for the same VBA password that protects all the code .. and if it is entered correctly .. opens the password as normal ?

Thanks
Bill
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try the following:
Code:
Private Sub Workbook_Open()
Dim StartDate As Date
StartDate = "04/16/2002"
If DateDiff("d", Now, StartDate) >= 30 Then PasswordCheck = InputBox("Password has expired, enter password")
If PasswordCheck <> "password" Then
Application.DisplayAlerts = False
ThisWorkbook.Close
End If
End Sub
 
Upvote 0
dont rely on Excel protection is aweful and stop advance user for about 3 1/2 seconds be for we rip it apart, but will keep out the non advanced user or about 5 seconds.

just to say so not relying on this to much easy hacked...
 
Upvote 0
I am confused. It seems the code above closes the workbook with no message appearing.

Am I doing something wrong?
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top