Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2008, 10:28 AM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Making an Excel File expire

I am using Excel 2007 (although the file I am asking about was created in an earlier version and has the .xls extension - and I want to leave it in the older format).

I have an Excel file where the user can click a button that starts a VBA macro to play a business game. There is another button to start the game over with a different set of demand characteristics. I’d like to be able to make the file expire after about 2 months so users can no longer access the game (don't know if this is VBA). If this is not possible, I’m wondering if there is a way to add an IF statement to the VBA macros that will “kill” the file after a certain date – I’m thinking the macro may be able to erase the entire spreadsheet? (and maybe immediately save it), so it is blank? – or maybe there is a better way?

I’ve noted some code as to how to get exact dates, but I need a "greater than a date" and I can’t quite put it all together. Can anyone help?

Thanks very much
 
Old February 4th, 2008, 05:45 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Well, dates respond to the regular comparison operators. The two operands must both be dates, but with that caveat, you should be able to use >, <, etc.

Just looking at this, without any research, I would put a date into the registry for this file, then retrieve it, and make the comparison upon opening the file. As the first statement of the routine that initializes this "game," I would test the retrieved date. If the date is out of range, exit the sub. The phenomenon will be that nothing at all happened when trying to start the game.

(Bear in mind, clever individuals will find what's happening in the code, and will circumvent it.)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Making an Alteration to an VB Codebehind file Nostromo77 ASP.NET 2.0 Basics 4 April 24th, 2007 08:11 PM
OWC making Excel with bar charts mondayisgreat Classic ASP Components 0 March 2nd, 2006 02:24 PM
Making a LRC calculator in Excel? wilded Excel VBA 3 March 25th, 2005 04:47 PM
Problem in making database file address virtual akhilvira ASP.NET 1.0 and 1.1 Basics 0 January 4th, 2005 01:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.