How to block macro execution after a specific time (license end)?

Viewed 88

I'm a VBA beginner. An excel of the company has already been well edited with multiple macros long time ago and it will be used by our clients. The problem is we want to block their utilisation of macros in several months after the project is finished. Is there a simple way that all macros will be deactivated when coming to a specific date or a password of protection will be activated from a certain date? Thank you in advance !

1 Answers

You could implement a Sub which does a RaiseError if the date is later than a certain value, then call this Sub from all your macros as their very first operation.

Now, when you provide these functionalities to the clients/users, you will only have to override the date you compare the current date with.

This is how you can get today's date in VBA: https://www.automateexcel.com/vba/todays-current-date/ This is how you can compare two dates in VBA: Compare Dates in VBA

Related