Help, I goofed up!

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
710
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Morning All!

I found this short code on the net last night and figured I would try it out.
Code:
Sub Workbook_Open()
If Date <=  7/29/2011 Then Exit Sub
MsgBox "This workbook has expired.", 48, "Goodbye."
With ThisWorkbook
    .Saved = True
    .ChangeFileAccess xlReadOnly
    Kill .FullName
    .Close False
  End With
End Sub
Now every time I open a new blank workbook, I get the MsgBox saying the expired phrase. I looked for the code inside the new WB and can not find it. What has happened? Why can't I stop this from happening?
Can anyone please give me a hand with this, I need to get this cleared up!
Thanks.
Pujo
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Perhaps you placed the code in your personal.xls.

To prevent the code from running hold down the Shift key whilst opening a workbook.
 
Upvote 0
Holding down the shift key doesn't stop the code from running.
I have held down shift, right click and open, as well as holding shift and left click to open, the code still runs. I do not have a personal.xls showing in the vba editor window.

What else can I try?:confused::confused:
 
Upvote 0
Ok, I think I got it.
I went to the XLSTART folder, found the personal.xls and removed it.
Everything worked great after that.
Thanks for the quick reply!

Have a great day!
Pujo
 
Upvote 0
Any way to put an expiratin date on a workbook to make it read only?Thanks,
Pujo
 
Upvote 0
Next time you test something with such dreadful capabilities, instead of:-
Code:
If Date [COLOR=red][B]<=[/B][/COLOR]  7/29/2011 Then Exit Sub
use:-
Code:
If Date [COLOR=red][B]<>[/B][/COLOR]  7/29/2011 Then Exit Sub
Then at least if it all goes pear-shaped, you only have to wait 24 hours before it starts working properly again! :)

To answer your question, any strategy that relies on VBA to enforce an expiry date will be dependent on your users having macros enabled. Unless you force them to enable macros by making the workbook unusable without them, that sort of approach will fail if they just disable macros, open the workbook with the Shift key held down or disable events before opening the workbook.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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