+ Reply to Thread
Results 1 to 5 of 5

not to open the file after exact date

  1. #1
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    not to open the file after exact date

    what i'm asking about is , is there someway to make the excel file not working after an exact date ... same like demo that depend on date
    or if there is more ideas plz tell me
    i want it work so normaly and to not open any more after a month or after a date i choose

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Without using a 3rd party application, you can't do *exactly* what you're after, but you can come close using macros.

    Essentially you hide all but a blank sheet and then protect the workbook. Create a workbook_open macro that will check the date, and if it's less than your specified date it will unhide any sheets you wish.

    If the user turns off their macros or sets security too high, the macro won't run and they won't be able to access any of the sheets/data.

    There are some drawbacks to this, of course.

    1. Worksheet protection can be broken rather easily. You'd also have to make sure to set a password on the vba project so users couldn't read the plain-text password for the worksheet(s).

    2. Even VBA password protection can be broken in under a minute.

    3. If a user sets their computer's clock back to a date prior to your cut-off date, they will be able to access the data.

  3. #3
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216
    i think this idea won't be bad ... but i don't know how to do date checking by the vba ... more over can i encrypt the vba password so no one could be able to read it even if they opened it somehow ???

    Quote Originally Posted by pjoaquin
    Without using a 3rd party application, you can't do *exactly* what you're after, but you can come close using macros.

    Essentially you hide all but a blank sheet and then protect the workbook. Create a workbook_open macro that will check the date, and if it's less than your specified date it will unhide any sheets you wish.

    If the user turns off their macros or sets security too high, the macro won't run and they won't be able to access any of the sheets/data.

    There are some drawbacks to this, of course.

    1. Worksheet protection can be broken rather easily. You'd also have to make sure to set a password on the vba project so users couldn't read the plain-text password for the worksheet(s).

    2. Even VBA password protection can be broken in under a minute.

    3. If a user sets their computer's clock back to a date prior to your cut-off date, they will be able to access the data.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi nasser,

    The following code could be used. There is an Open event and a BeforeSave event. I would recommend you:
    1. Insert a blank sheet (or use Sheet1). Protect it with a password (Tools -> Protection -> ProtectSheet) so it cannot be modified.
    2. Hide all of the other sheets (select them all and use Format -> Sheet -> Hide).
    3. Protect the workbook (Tools -> Protection -> Protect Workbook) with a password. When protecting, make sure 'Structure' is checked. Note the password you use, as it will be coded into the vba code.
    4. Open the VB Editor (ALT+F11), double-click on 'ThisWorkbook' in the left-hand column, and paste the two code snippets below into the right-hand window. Change the DateSerial to a date you want, and change any Password:="___" field to the workbook password you set earlier.
    5. In the VB Editor window, click Tools -> VBAProject Properties -> Protection Tab. Check 'Lock project for viewing' and set a password.
    6. Save your workbook and close it. This should hide all of the sheets except the first, and it hides them in such a way that even if they unprotected the sheet or workbook they couldn't unhide the hidden sheets without breaking into the VBA code.
    Please Login or Register  to view this content.
    This Open event determines if today's date is less than or equal to a date you specify (DateSerial(2007,9,19) for example), and if so, unhide the data sheets. If not, pop up a message box letting the user know. The loop through the sheets can be customized, as the one below simply assumes your first sheet (originally "Sheet1" if you have renamed it) will remain visible at all times.
    Please Login or Register  to view this content.
    This BeforeSave event unprotects the workbook, makes all the sheets VeryHidden again, then reprotects the workbook, and finally saves any changes to the data.

    Sorry for the novel.

    To answer your question about encrypting the passwords within the code.. the simple answer is no. You could probably throw together some obfuscating code so that it's not obvious what the password is (e.g. set a variable to hold a string, and then manipulate it multiple times until it generates the correct password without the user being able to see it, but if someone knew enough to get into your VBA they probably know coding as well and could decipher what you're doing.

    Regardless of the password (Worksheet, Workbook or VBA), they can all be cracked, and you don't need to ever know the original password. I, and many other people, can crack them, clear them and set them to whatever we want afterwards all without knowing what you originally set them to.

    If you need some of the code customized because it doesn't fit your workbook, please upload the workbook and we can probably take care of that for you.

  5. #5
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216
    Thank u very much ... and i will try it and tell u if i misundestood how to do it ... thanks alot for ur concern wishing u a gret good luck and nice time


    Quote Originally Posted by pjoaquin
    Hi nasser,

    The following code could be used. There is an Open event and a BeforeSave event. I would recommend you:
    1. Insert a blank sheet (or use Sheet1). Protect it with a password (Tools -> Protection -> ProtectSheet) so it cannot be modified.
    2. Hide all of the other sheets (select them all and use Format -> Sheet -> Hide).
    3. Protect the workbook (Tools -> Protection -> Protect Workbook) with a password. When protecting, make sure 'Structure' is checked. Note the password you use, as it will be coded into the vba code.
    4. Open the VB Editor (ALT+F11), double-click on 'ThisWorkbook' in the left-hand column, and paste the two code snippets below into the right-hand window. Change the DateSerial to a date you want, and change any Password:="___" field to the workbook password you set earlier.
    5. In the VB Editor window, click Tools -> VBAProject Properties -> Protection Tab. Check 'Lock project for viewing' and set a password.
    6. Save your workbook and close it. This should hide all of the sheets except the first, and it hides them in such a way that even if they unprotected the sheet or workbook they couldn't unhide the hidden sheets without breaking into the VBA code.
    Please Login or Register  to view this content.
    This Open event determines if today's date is less than or equal to a date you specify (DateSerial(2007,9,19) for example), and if so, unhide the data sheets. If not, pop up a message box letting the user know. The loop through the sheets can be customized, as the one below simply assumes your first sheet (originally "Sheet1" if you have renamed it) will remain visible at all times.
    Please Login or Register  to view this content.
    This BeforeSave event unprotects the workbook, makes all the sheets VeryHidden again, then reprotects the workbook, and finally saves any changes to the data.

    Sorry for the novel.

    To answer your question about encrypting the passwords within the code.. the simple answer is no. You could probably throw together some obfuscating code so that it's not obvious what the password is (e.g. set a variable to hold a string, and then manipulate it multiple times until it generates the correct password without the user being able to see it, but if someone knew enough to get into your VBA they probably know coding as well and could decipher what you're doing.

    Regardless of the password (Worksheet, Workbook or VBA), they can all be cracked, and you don't need to ever know the original password. I, and many other people, can crack them, clear them and set them to whatever we want afterwards all without knowing what you originally set them to.

    If you need some of the code customized because it doesn't fit your workbook, please upload the workbook and we can probably take care of that for you.

+ 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