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.

Expiration Date for Excel Programs

Written by Allen Wyatt (last updated June 22, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


6

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:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Multiple Document Users

If you have a group of people working on a single document, you may wonder what tools are available in Word to facilitate ...

Discover More

Specifying Superscript Text

Applying different formatting to the text within a cell can seem a bit confusing. This is certainly the case when it ...

Discover More

Finding All Camel-Case Words

If you need to find words that mix uppercase and lowercase characters together, you will appreciate this tip. Here I show ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Converting Cells to Proper Case

When storing text in a worksheet, you may have a need to change the case of that text so that the initial letter in each ...

Discover More

Converting Numbers Into Words

Write out a check and you need to include the digits for the amount of the check and the value of the check written out ...

Discover More

Converting Text to Numbers

Import information from a program external to Excel, and your numbers may be treated as text because of the way that the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 0 + 7?

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

GAUTAM BASU

I applied above macro in peronal workbook, with trial period has expired
when i hold shift key Personal Macro not opening..Please help


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.