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

by Allen Wyatt
(last updated December 12, 2015)

4

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.

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

Smushing Text Together

Word gives you control over how your text appears on the page. This includes adjusting how close letters are to each other ...

Discover More

Complex Lookup Formulas

If you need to combine information in some of your cells in order to produce a result needed to, in turn, look up other ...

Discover More

Moving Captions with Pictures

Put a caption with a picture and you'd probably like the two elements to behave like they belong together. If you are tired ...

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)

Selecting All Visible Worksheets in a Macro

Do you need your macro to select all the visible worksheets (and just the visible ones)? It's not as easy as it sounds, but ...

Discover More

Controlling Display of Toolbar Buttons

You can assign your macros to a series of custom toolbar buttons, but you may only want those buttons to be visible when a ...

Discover More

Determining If a Number is Odd or Even

If you need to know whether a particular value is odd or even, you can use this simple formula. Designed to be used in a ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 7 + 7?

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.