Results 1 to 14 of 14
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stop to use this wbook.... (2000 sr 1)

    ... in event Workbook_Open() is possible to insert this controll:

    1) Read the date of creation of wbook. (example 01/12/2005)
    2) If the user open the wbook (example 17/12/2005), and the date is out of 15 days of date creation, show msgbox "Attention you can use this wbook only for 15 days!", click "OK", close auomaticllly the wbook without save it...

    hope i am clear

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    That won't help, Sal. If the user doesn't allow macros to run, or keeps down the Shift key when opening the workbook, the Workbook_Open procedure will not run.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    OK... Have other suggestion?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    I don't think there are really good ways to protect an Excel workbook. Users intent on it will almost always be able to bypass the protection. (For example, there are utilities to modify the create date of a file.)

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    ... But this startegy not is for the level of knolegment of mine users...

  6. #6
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    I did raise a similar question in <post:=499,737>post 499,737</post:>

    (Events for me changed and I didn't need to instigate it. Sorry for not replying to your last post Don!)

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    You could use this, but as noted, it is not secure:

    Private Sub Workbook_Open()
    If Date - Int(ThisWorkbook.BuiltinDocumentProperties _
    ("Creation Date")) > 15 Then
    MsgBox "You can't use this workbook any more!", vbExclamation
    ThisWorkbook.Close False
    End If
    End Sub

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    ... And if inested to "Created Date" is possible to use a date prsent into cell G1?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    Of course!

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    I have used this but not work...
    G1 is formated gg/aa/aaaa

    Sub NON_PUOI()
    'DATA_MAX As DATE
    DATA_MAX = CDate(Range("G1"))
    If CDate(DATA_MAX) > 15 Then
    MsgBox "NON PUOI PIU' USARE QUESTO FILE, ATTENDI NUOVO REPORT!", vbExclamation
    ThisWorkbook.Close False
    End If
    End Sub

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    The line

    If CDate(DATA_MAX) > 15 Then

    is not correct. See the original code - you must replace Int(ThisWorkbook.BuiltinDocumentProperties("Creati on Date")) with the value of G1.

  12. #12
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    .. for test i have insert in G1 26/12/2005 the macro not go to the msgbox!
    Sub NON_PUOI()
    If Date - CDate(Range("G1")) > 15 Then
    MsgBox "You can't use this workbook any more!", vbExclamation
    ThisWorkbook.Close False
    End If
    End Sub

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    Of course not. Your code will display the message box if the current date is more than 15 days LATER than the date in G1. Today, it is EARLIER than 26/12/2005, so nothing happens. If you enter 20/11/2005 in G1, the message box should be displayed when you open the workbook.

  14. #14
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop to use this wbook.... (2000 sr 1)

    Have you considered using the F8 step function to find out why it doesn't work? It can be a lot quicker than asking questions all the time.

    If you simply add the line
    <code>a = Date - CDate(Range("G1"))</code>
    and hover your cursor over 'a' to see the value as you step through, what do you get?
    And is it > 15?

Posting Permissions

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