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

Adding Vertical Lines at the Sides of a Word

Vertical lines are even easier to add around a word than are horizontal lines. There are a variety of methods you can use ...

Discover More

Understanding Decimal Tabs

Word offers a variety of tabs that define different ways to align text. If you need to align numeric values, you'll ...

Discover More

Disabled Macros

Do your macros seem to be disabled on your new machine? It could be because of the security settings in Excel. Here's ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Determining the Length of a String

Macros are great for working with strings, and one of the most commonly used string functions is Len. This tip explains ...

Discover More

Deleting Every X Rows

Grab some info from a source other than Excel, and you may find the need to delete a certain pattern of rows from a ...

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 6 - 0?

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.