Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Expiration Date for Excel Programs.
Written by Allen Wyatt (last updated June 22, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003
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 = "09/30/2015" 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 (2590) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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!
When creating macros, you'll often have a need to select different cells in the worksheet. Here's how to select the first ...
Discover MoreWant to add a bunch of blank rows to a your data and have those rows interspersed among your existing rows? Here's a ...
Discover MoreNeed to select a cell using a macro? Need that selection to be relative to the cell you currently have selected? Here's ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-01-11 12:41:52
Victor Tenev
Great article, saves great deal of time and effort!
Much appreciated work,
Cheers, mate!
2019-08-26 15:24:50
Roy
Word to the wise:
DO NOT try to be clever and use this as the trigger for a "failure bomb" to get support revenue when you cannot negotiate continuing license payments into your contract. ESPECIALLY when it's the US military you did the work for.
Been reading lately about a few of these involving mostly the military. One fellow got some jail time and has to pay back $150,000. Apparently the military is actively looking for this kind of thing now. Not everyone will have enjoyed the nice cars and vacations that fellow did, but apparently they don't consider size of fraud to be more important than the fact of fraud.
Seems likely at least large companies might be too. But it isn't nice to victimize the small companies rather than the monopolists just because they don't catch on. So... just be careful that you do not end up on the wrong side of law, regulation, or contract, if you do this kind of thing.
(Government contracts at any level are so fraught with bizarre laws, regulations, and requirements — not to mention their interpretations in court — that I'd never plan on doing it for that class of contract in any case.)
2016-04-15 10:40:50
Gautam basu
Yes, it is working
Thanks
2016-04-14 15:51:02
Mohamed
@GAUTAM BASU, I hope you've managed to solve your problem. If not, you may rename your workbook (or save it in another folder), open it and choose NOT to enable macros. You can then manually change the expiry date in your VBA code.
2016-02-18 06:48:58
Barry
Holding down the "Shift" key when opening the file 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-02-18 00:30:11
I applied above macro in peronal workbook, with trial period has expired
when i hold shift key Personal Macro not opening..Please help
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments