Creating macro with expiration date

bukimi

Board Regular
Joined
Apr 12, 2017
Messages
105
Office Version
  1. 2019
Platform
  1. Windows
Hello!

Today I need some creativity.
I need to protect my VBA code from unauthorized sharing, but it must be a discreet protection (that is, all password protection is not an option).

Currently I'm thinking about setting some expiration date hidden in the code (most possibly, people who will receive any unauthorized copy will not know much about VBA).
Right now I have something like this:
Code:
[COLOR=#333333]If Date > DateValue("01-12-2017") Then[/COLOR]
[COLOR=#333333]End[/COLOR]
[COLOR=#333333]End If[/COLOR]
It will just quietly exit macro without executing its code. A beginner will just think that my code doesn't work.

Still, I would like to have something less obvious. With code like that, it's sufficient to find date (like year) with CTRL-F and change it.
Can you give me some advice on some more hidden ways to code in a date after which the code will not work anymore?

Thank you in advance!
 
I don't see how SETTING any security is anywhere similar to request of BREAKING a security measure.
If I ask you to install alarm in my car you would be as suspicious as if I asked you to tell me how to disable car alarms?

I don't see the point of discussing it any further. If my thread is a violation of some regulations of this forum, please do inform me about that.

My comment was directed towards steve the fish's comment about "not difficult to crack".
In any event, I'm sure you will appreciate that some people sometimes aim for deliberate sabotage.
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
another version with message box saying file expired bye bye.... then closes the workbook.

Code:
Private Sub Workbook_Open()
Dim udate As Date, xdate As Date
Dim curWs As Workbook


Set curWs = ThisWorkbook
udate = Date
xdate = "06/01/2017"


    If udate >= xdate Then
        With curWs
            MsgBox "File expired, bye bye"
        End With
    End If
    
    curWs.Close False


End Sub
 
Upvote 0
another version with message box saying file expired bye bye.... then closes the workbook.
This one is quite good, but still someone will probably just alter 2017 to 2030 and go on...
 
Upvote 0
This one is quite good, but still someone will probably just alter 2017 to 2030 and go on...
ok i get your point on we shouldne be discussing this but the thing is, this is a forum and i am only sharing what the TS is trying to accomplish. Its in his discretion whether he will literally copy the code that we post here or tweak something to improve the code provided. Anyway back on topic.

Im really not sure if this will work though it can be improved later.
- Create a login sheet, Make ALL working sheet VERY HIDDEN except one which is your login sheet, password protect your VBE before deploying to users.
- the user cannot use the worksheet unless they login.
- once they login the hidden Sheets will be visible for work.
- once close save/not save the Sheets will be VERY HIDDEN again to protect your code.

maybe just a thought.
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,578
Members
449,174
Latest member
chandan4057

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