Need VBA code to make app expire after period of time

T

TJ

Can someone provide some sample code or reference to make an
application expire after a period of time.

Thanks.
 
N

NDBC

At the start of the sub put something like

If Now() > "date and time" Then
Exit Sub

Else

'the rest of you sub goes here as normal.

My only concern is I'm not sure how to put in the date and time that you
want finish at. Another alternative is to put the date time in cell AA1

If Now() > Sheets("Sheet1").Range("AA1") Then
Exit Sub

Else

'the rest of you sub goes here as normal.


Hope this helps you get on track anyway.
 
N

NDBC

I just tried this and it worked

If Now() > "20/08/2009 3:32pm" Then

but

If Now() > "20/08/2009 15:32" Then

didn't work.
 
P

Phil Hibbs

NDBC said:
I just tried this and it worked
If Now() > "20/08/2009 3:32pm" Then
but
If Now() > "20/08/2009 15:32" Then
didn't work.

What's going on there? Is it converting Now() to a string using the
user's locale, and then comparing it to your hard-coded string in your
locale? Or does the string get converted to a Date value and then
compared? I think you need to protect your code from locality issues
by explicitly formatting the date and comparing, e.g.

If Format(Now(), "yyyy-mm-dd") >= "2009-08-20" Then

Phil Hibbs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Cause Macro to Expire 5
Database Expiry 2
encrypting MS document with expiration date 1
Trial version 3
Tiny URL 6
Setting time period for password to expire 1
VBA call xlfit 1
How to expire application 2

Top