Excel provides a robust development environment of which many people take full advantage. In fact, many people have written entire application programs using VBA with Excel as the framework.
If you do program development in Excel, you may be wondering if there is a way to write your program so that it will no longer work after a specific date. Fortunately, this is rather easy. One solution is to use something like the following as an Auto_Open macro:
Sub Auto_Open() Dim exdate As Date exdate = "12/31/2020" If Date > exdate Then MsgBox ("You have reached end of your trial period") ActiveWorkbook.Close End If MsgBox ("You have " & exdate - Date & "Days left") End Sub
If the date on the system running the program is greater than the date specified in the exdate variable, the user will see a message box indicating that their trial period has expired. When the user clicks on the OK button, the workbook closes. If the trial period is not over, then the message box indicates how many days are left in the period.
Of course, if you put a macro such as this in your application, it may stop you from opening the workbook to make program changes. The obvious way around this, of course, is to hold down the Shift key as you open the workbook. Doing so stops the Auto_Open macro from running. If your users know this, they can bypass the expiration check just as easily as you, however. The solution is to place similar checks within other macros that cannot be bypassed and that are essential to your program.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10230) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Expiration Date for Excel Programs.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Want to get rid of all the zero values in a range of cells? This tip provides a couple of different ways you can ...
Discover MoreDo you often need to know the difference between two values in your worksheet? This tip shares a quick little macro that ...
Discover MoreWith a little bit of work, Excel allows you to format individual characters of the text you place in a cell. If you want ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-08-06 12:34:48
anil kut
Please refer to
If you do program development in Excel, you may be wondering if there is a way to write your program so that it will no longer work after a specific date. Fortunately, this is rather easy. One solution is to use something like the following as an Auto_Open macro:
code is:
Sub Auto_Open()
Dim exdate As Date
exdate = "12/31/2020"
If Date > exdate Then
MsgBox ("You have reached end of your trial period")
ActiveWorkbook.Close
End If
MsgBox ("You have " & exdate - Date & "Days left")
End Sub
I have done it, please I am open to open the excel file and work on it. I need a file which either do not open or force closed even after opening it.
Regards
2020-01-11 12:37:43
Victor Tenev
Thank you Allen,
this article is greatly appreciated! It saves a lot of effort and time.
Cheers, mate! :)
2019-04-30 15:34:17
Saru
Very good tip
Now say I want to extend the expiry date by one more year
Is there a way to do that without sending them
Another excel file
Any ideas or workarounds
2018-07-16 23:01:11
Darren E
Good advice Barry! It should be noted that the shift key / disable macros bypass method doesn't work if the file is an add-in. But the most important advice - make sure you keep a personal copy of the file *minus* the expiry date check.
2018-07-16 05:58:20
gerdami
Related: https://excelribbon.tips.net/T012812_Self-Deleting_Macros.html
2016-01-19 06:02:24
Barry
The simplest way is to hold down the "Shift" key when opening the file. This disables macros thereby bypassing the expiry check.
To get around a system time change, it is possible to get the time from the Internet (a working Internet connection is, of course, required for this to work). There are lots of code examples of this on the Internet.
All the worksheets should be set to "VeryHidden" whenever the workbook is saved or closed, except for one worksheet which advises the User to enable macros in order to access the Workbook, and unhidden when the workbook is opened provided the license date hasn't expired.
2016-01-18 22:13:40
Eric
one way to bypass the expiration date is to change the system date to older date and run the excel file again. hope it helps .
2015-04-21 02:01:57
thanks a lot.....
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments