Time Trial for Excel Sheets

torque

New Member
Joined
Apr 15, 2004
Messages
20
Is there a way to make an Excel sheet expire (ie. become useless or password protected) after a certain number of uses or days?

thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi,

What about this? Right click the sheet select view code then put this in:

Option Explicit

Private Sub Worksheet_Activate()

If Now > #5/7/2004# Then
MsgBox ("Worksheet has expired"), vbOKOnly
ActiveSheet.Protect Password:="password"
End If

End Sub

Watch the american date format! Modify accordingly should do the trick.

Any use?

James
 
Upvote 0
i put that in and nothing happens. i even set the date back...
Where'd you put it? Jimbo's code goes in a worksheet specific module, not a general module.

Note that as complex as you want to make this, all someone has to do is set their system clock back, like you did to override the code. They're are other ways to sking this cat, but if you're trying to make a commercial application, then you'll need to be better than crafty and come up with some EULA's as well.

Hope that helps,

Smitty
 
Upvote 0
Ok, it now works when I go to that specific worksheet from another worksheet. But all it does is pop up that box, then if you click OK you can continue to use the sheet.

Is there code that will close the worksheet after you hit OK on the box?

(Here is what I have going on right now: I spent about 30 hours working on this huge excel workbook for a company and now I am having a hard time getting them to pay. I can't just send them a non-working file to replace the old one. What I want to do is send them one with a time trial of 15 days from now and then it stops working, and tells them they need to pay me. This gives them 15 more days from now to pay.)
 
Upvote 0
Try adding something like this to the code:
Code:
    ans = MsgBox("Your trial period has expired" & vbCrLf & _
        "Time to pay up!", _
        vbOKOnly, "Trial Period Expiration")
    If ans = vbOK Then ActiveWorkbook.Close False
You can also see about integrating "Kill Filename" in there to delete the workbook.

HTH,

Smitty
 
Upvote 0
Ok so I put this in and now it doesnt work at all. I am an idiot.


Option Explicit

Private Sub Worksheet_Activate()

If Now > #5/7/2004# Then
ans = MsgBox("Your trial period has expired" & vbCrLf & _
"Time to pay up!", _
vbOKOnly, "Trial Period Expiration")
If ans = vbOK Then ActiveWorkbook.Close False
End If

End Sub
 
Upvote 0
Hi torque, If you want them to be able to open / use the rest of the workbook and just not that one sheet, try replacing the original suggestion with this.
Code:
Option Explicit

Private Sub Worksheet_Activate()

If Date > #6/7/2004# Then
MsgBox "This worksheet has expired. (Pay up sucka!)"
ActiveSheet.Protect "password"
Sheets(1).Select
Sheets("YourSheetName").Visible = xlVeryHidden
End If

End Sub
As Smitty pointed out, it's not fool proof because Excel is just not a real secure environment, but it might get the point across. We can get more dastardly if you like.... :devilish:
Dan
 
Upvote 0
Nah, but what's not working?

Did you Dim "ans"?

Test with today's date and remember Jimbo's comment about the date format.

Smitty

EDIT: Heya Dan! Hope you and the Missus are doing well! Dastardly eh? :wink:
 
Upvote 0
thanks you guys. I dont know what DIM "ans" means. So I probably didnt do it.

As far as the one worksheet goes...it is the first worksheet that is opened that I want blocked. It seems like i have to swith to another worksheet and come back to this one for this to work. I really like the idea of it automatically deleteing the whole file in 15 days if that is possible.

Also everytime i fire it up now it asks if i want to enable macros. I click YES then the worksheet opens.

EDIT::: HALFACE: I tried yours and it works pretty good. How can i have it hide multiple sheets, and how do i get them back?
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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