Consulting

Results 1 to 18 of 18

Thread: On line date for setting expiry period

  1. #1

    On line date for setting expiry period

    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.

  2. #2
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,008
    Location
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    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.

  4. #4
    I couldn't read the first link but the second had differences so slight that it might as well be a cross post.
    2+2=9 ... (My Arithmetic Is Mental)

  5. #5
    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.

  6. #6
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,008
    Location
    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?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  7. #7
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by sujittalukde
    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 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 )
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  8. #8
    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.

  9. #9
    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.

  10. #10
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by sujittalukde
    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)
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  11. #11
    VBAX Mentor
    Joined
    Sep 2004
    Posts
    431
    Location
    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.
    Thank you for your help

  12. #12
    Thanks johnske, you trick can be used. however in the mean time, ndendrinos has also given some clue. Lets hope this may help.

  13. #13
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    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
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  14. #14
    Its all right. Actually your trick in the last post is helpful.

  15. #15
    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.
    2+2=9 ... (My Arithmetic Is Mental)

  16. #16
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by unmarkedhelicopter
    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)
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  17. #17
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    Hi sujittalukde

    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
    this but i preserve this.

    here is the open source code with attached file



  18. #18
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •