+ Reply to Thread
Results 1 to 10 of 10

VBA-code for opening a file max x times

  1. #1
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    287

    VBA-code for opening a file max x times

    Hello everybody

    I am makeing a file which has a ‘status’ as a demo. Because it’s just a demo I want it to be opend max a certain number of times.
    I saw somewhere a suggestion of a VBA statement called SaveSettings and GettSettings but I am stuck.

    Can someone help me with a VBA code which will protect the file for being opened more that lets say five times ?

    Saturn
    Last edited by Saturn; 06-03-2013 at 09:51 AM.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA-code for opening a file max x times

    What do you want to have the file do when it is opened more than fives times?
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    287

    Re: VBA-code for opening a file max x times

    Then I want a message box telling the user that the file cant be opened because the file has reached its maximum usage.

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA-code for opening a file max x times

    The only way I can think of doing this is by embedding a counter in the file on a hidden sheet and doing it that way.

  5. #5
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    287

    Re: VBA-code for opening a file max x times

    Any other suggestions ??

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA-code for opening a file max x times

    This could work, make a sheet named counter and hide it.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    287

    Re: VBA-code for opening a file max x times

    Thanks a lot! but it seems not to work.
    Please see the attachement.
    Another thing is that this excel-file will contain many sheets, so its a need to prevent to open the entire workbook, not a specific sheet.
    Attached Files Attached Files

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA-code for opening a file max x times

    The code needs to go in the workbook module.

    Try this.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    287

    Re: VBA-code for opening a file max x times

    This works! .. so thanks a lot JanaDave and I can use it

    However it doesnt work exactly how I thought because the VBA is counting only if the user makes an update.
    Is there any solution that VBA is counting up to the max number even if the user doesnt make any update / save the file without update ??

  10. #10
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA-code for opening a file max x times

    Try this, this will save the workbook without any updates made.
    Attached Files Attached Files

+ 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