+ Reply to Thread
Results 1 to 9 of 9

Trial Version Counter

  1. #1
    Forum Contributor
    Join Date
    07-13-2007
    Posts
    151

    Trial Version Counter

    I'm playing around with the concept of restricting a Workbook such that it can only be opened a predetermined number of times. (Not a time frame restriction.)

    I've tried the following code but it seems the GetSetting / SaveSetting commands aren't doing what I need them to do.

    I was attemtping to have it pull the counter setting from the registry if it was there, if it wasn't there the default of 0 would return and you'd treat that as the first time the workbook was ever opened and set the coutner to 5. Next time through the counter setting should <> zero, thus do the other bit, and so on.

    any ideas?

    HTML Code: 
    I realize this code doesn't address what happens when the number of times is reached. I'd want that circumstance to thorow up another msgbox announcing your trial is expired, and then close the workbook. Right now I was just trying to figure out how to store the counter value so that I could use it the next time I open the workbook.

    I'm still pretty new to all of this.

    Any help much appreciated.

    Thanks,

    Shred

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Here is 1 way


    Please Login or Register  to view this content.
    Things to watch for
    Macro security stopping macro running
    Cell A1 being deleted
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor
    Join Date
    07-13-2007
    Posts
    151
    Mudraker:

    Thanks for your reply. I learned something new reading the Help file about the ID property of the Range Object. Neat ID to use this element to contain your counter in this example. Makes it kind of stealth for most users.

    However, I didn't get the code to work in my example. I got a type mistmatch error on the first line when I ran it.

    I can't figure it out. Is there a problem with a null value the first time through and thus you can't add a 1 to it? I don't know.

    I had a similar question while trying to figure a way to accomplish this before. how do you get the initial value in there, without resetting it each time the workbook open procedure kicks off? That's when I got down the path of checking to see if it's zero, and if it was, to then set it up to 5 so I could work down off it. And using the savesetting to keep it in the registry for next time.

    I lke the idea of not having to write to the registry. There would plenty of places to hide the ID in the workbook.

    Thanks for your reply. I already learned something new!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your counter does not exist initially, so it cannot have a value of 0.
    You don't give the counter a value before testing.
    It ill eventually reach 0, then your code would allow use again


    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    This will fix the error in the code I posted earlier

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-13-2007
    Posts
    151

    Thanks Roy UK

    thank you...Your code worked well. I've tailored it a bit for my scenario.

    I have a question though about preventing the user from escaping out of the code, and then hitting Continue. That allows them to keep using the workbook. (I'm not sure if this sort of add-on question violates forum rules. If so, please advise.)

    I put a password on the VBA project, and that disabled the Debug button in the window that comes up if you interrupt the code with a CTRL+BREAK key. But it still alows them to click Continue, which puts them back to the workbook, fully able to use it.

    I read in the Help that the User Interrupt error code is 18, but I haven't been succseful in inserting some error handling code to prevent the user from working around my code in the Case that closes the workbook when the trial has expired.

    Any ideas? I'm wanting to be able to give a file to someone to use "X" number of times, and thereafter it pops up a msgbox, and then closes. I've got that bit working, but I can get around it with CTRL BREAK and then clicking Continue.

    Thanks,

    Shred

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-13-2007
    Posts
    151

    Correction

    I meant to say the End button. The Continue button allows the code to complete, extiting the workbook as desired. Clicking the End button puts the user into the workbook, able to continue using it.

    Shred.

  9. #9
    Forum Contributor
    Join Date
    07-13-2007
    Posts
    151

    Thanks Roy

    I hadn't seen your reply when I posted the correction just now.

    I get it. Thanks for the help! I'm enjoying learning these new skills!

    Shred

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1