Need VBA code to make app expire after period of time

  • Thread starter Thread starter TJ
  • Start date Start date
T

TJ

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

Thanks.
 
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.
 
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.
 
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.
 
Back
Top