PDA

View Full Version : On line date for setting expiry period



sujittalukde
06-28-2007, 01:42 AM
Sub Auto_Open()
Dim exdate As Date
exdate = "27/06/2007"
If Date > exdate Then
MsgBox ("This file has expired")
ActiveWorkbook.Close
End If
MsgBox ("You have " & exdate - Date & "Days left")
End Sub


AS you can see from the code this code is subject to computer system date and one can reject the expiry changing the system date.

Can this date be made online sysytem ie the date will be independent of systems date rather it will take date from online clock from any site.

Simon Lloyd
06-28-2007, 04:31 AM
Cross posted http://www.excelforum.com/modcp/index.php here and http://www.mrexcel.com/board2/viewtopic.php?t=279813 here!

sujittalukde
06-28-2007, 04:38 AM
Dear Simon, perhaps you have not read the posts at those forums otherwise you would have seen the difference between the posts. Please dont be hurry in such cross posting replies.

unmarkedhelicopter
06-28-2007, 04:58 AM
I couldn't read the first link but the second had differences so slight that it might as well be a cross post.

sujittalukde
06-28-2007, 05:21 AM
Please read the posts carefully which are written in plain and simple English. In those posts I am searching for a solution which will expire a WB after some days of opening of the file and obviously on the basis of system date which say for eg after 7 days as because the code I have provided contains a fixed date so creates a problem for me to distribute a file on trial basis.

In this post my requirement is that the time should not be related to system date rather than it should take the date from some online system so that even if the user changes system date the file should not work.

Now dear unmarkedhelicopter, how can you justify the posts are cross post?

I know the rules better and if the posts were similar, I self would have disclosed the same here also.

Simon Lloyd
06-28-2007, 06:27 AM
A simple poser!: What if the user of the workbook does not have internet access?, the workbook would not pick up a start date......or perhaps you haven't given us the whole story?

johnske
06-28-2007, 06:35 AM
Sub Auto_Open()
Dim exdate As Date
exdate = "27/06/2007"
If Date > exdate Then
MsgBox ("This file has expired")
ActiveWorkbook.Close
End If
MsgBox ("You have " & exdate - Date & "Days left")
End Sub


AS you can see from the code this code is subject to computer system date and one can reject the expiry changing the system date.

Can this date be made online sysytem ie the date will be independent of systems date rather it will take date from online clock from any site.Why bother? You just need more checks and balances to offset the possibilty they've reset the clock - have a look here (http://vbaexpress.com/kb/getarticle.php?kb_id=475&PHPSESSID=8b30720fa466d7f0896e8054cb211ae7) to get some more ideas. (BTW - don't give them a daily countdown to the expiry date, you're only inviting them to reset the clock :))

sujittalukde
06-28-2007, 06:39 AM
Saying that I have not given the whole story is not correct. What I said is that the time should be based on online clock . It could be a matter of issue which can be answered. If the user does not have internet connection then the same could be handled in manner -

The code will check for internet connection and if not found it will not open the WB & display a message that "Not connected to internet. Get connected to access to WB" If it is possible, else even if the macro opens the WB the other macros will not work, if possible.

sujittalukde
06-28-2007, 06:42 AM
Thanks johnske, I tried that earlier also but that was also dependant on the system clock Can some modifications be done there to take teh time online. As I dont have depth knowledge of VBA I cant do that and thats why searching a help.

johnske
06-28-2007, 07:07 AM
Thanks johnske, I tried that earlier also but that was also dependant on the system clock Can some modifications be done there to take teh time online. As I dont have depth knowledge of VBA I cant do that and thats why searching a help.As I said - why bother? I would never reset my system clock just to extend the free use of someones program and i really can't see anyone else doing it either...

If you've given them (say) 30 days free use and then a notice that they've only got one days use left you're just inviting them to (maybe) reset the clock.

Once they've had their free use just cut them off without warning (after saving their previous data of course) and render the program useless so they can't resuscitate it, or just kill it (there's a link I've given there to show how to do that) - the method i've shown there leaves a hidden text file which prevents them downloading and re-installing a fresh version of your file.

You could also modify that to not only record the expiry date, but the date last used and a check to see if the current system time is earlier than the last-used time (i.e. if they've reset the clock)

ndendrinos
06-28-2007, 04:36 PM
For the benefit of sujittalukde & mine the attachment included retrieves the time from the Internet (Naval Academy USA)
I thought of doing an =LEFT in B1 with the result : June. 26 (I do not know how to get rid of the dot between June and 26)
If a condition can be added to the code to the effect that if vale in B1 IS June. 26 to close the file I think that might answer the original question.

sujittalukde
06-28-2007, 10:17 PM
Thanks johnske, you trick can be used. however in the mean time, ndendrinos has also given some clue. Lets hope this may help.

johnske
06-28-2007, 10:48 PM
Problem with that approach is that some ppl are not even on the internet or, they may want to use your prog on a laptop while travelling and are disconnected. (or the net may just be 'down' for a long period)

In addition, some quite honest ppl are on internet provider plans that may charge them by the hour or may otherwise allow them only limited time on the net (e.g. prepaid) - being treated as being (basically) dishonest and forced to connect every time they want to use your prog could cause dissatisfaction and resentment - all in all, it's certainly not an approach i'd take :)

sujittalukde
06-28-2007, 10:50 PM
Its all right. Actually your trick in the last post is helpful.

unmarkedhelicopter
06-29-2007, 04:18 AM
Johnske, your idea is a good one, but you'd have to make sure that daylight saving adjustments don't screw things up.
Come to that what about people who travel across time-zones with a laptop ? I never change the time but you can't be sure somebody won't.

johnske
06-29-2007, 04:51 AM
Johnske, your idea is a good one, but you'd have to make sure that daylight saving adjustments don't screw things up.
Come to that what about people who travel across time-zones with a laptop ? I never change the time but you can't be sure somebody won't.What's the greatest legitimate time change 13hrs? 25hrs? (inc daylight saving) - you could easily put that in as a tolerance for ppl moving permanently to a new time-zone. i.e. If Date/time is 13 (or 25) hrs less than previous time used Then (they've reset the clock so kill the file)

anandbohra
06-29-2007, 05:07 AM
Hi sujittalukde (http://vbaexpress.com/forum/member.php?u=9797)

the perfect solution i am giving here which u actually needs.

the thanks should be given to one who actually made this code i neither remember the forum nor the place from where i got :dunno
this but i preserve this.

here is the open source code with attached file:beerchug:

sujittalukde
06-29-2007, 05:16 AM
Hi anandbohra, actually this file is from kb of this site. The Author johnske has provided the link earlier also (Read 7th post of this thread)