+ Reply to Thread
Results 1 to 3 of 3

Protect Workbook Based on Dates

  1. #1
    Registered User
    Join Date
    02-17-2005
    Posts
    4

    Lightbulb Protect Workbook Based on Dates

    Hello... I need some help in finishing up with a macro that asks for a password when the file is opened after a certain dates. So if the dates in the computer is over the 15th day of the month, upon opening the spreadsheet it will ask for a password. Otherwise, it is okay. Thanks for all the help.
    -----------------------------------------------------
    Sub auto_open()

    Dim MyDate
    Dim SetDate
    Dim CompareDate

    MyDate = Format(Date, "mm/dd/yyyy")
    CompareDate = Mid(MyDate, 1, 2) & "/" & "15" & "/" & Mid(MyDate, 7, 4)

    If MyDate > CompareDate Then
    ActiveWorkbook.Password = "test"
    'MsgBox "Please Use a New Spreadsheet from the Server" & vbCrLf, vbOKOnly, "Outdated Spreadsheet"
    Else

    End If

    End Sub
    -----------------------------------------------------------------------------

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Yah_kid,

    Just needs a little tweak. Here it is.
    _________________________________________________________________

    Sub auto_open()

    Dim MyDate

    MyDate = Date

    If Day(MyDate) > 15 Then
    ActiveWorkbook.Password = "test"
    'MsgBox "Please Use a New Spreadsheet from the Server" & vbCrLf, vbOKOnly, "Outdated Spreadsheet"
    Else

    End If

    End Sub

    ________________________________________________________________


    Hope this helps,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-17-2005
    Posts
    4

    Question Protect Workbook based on Dates

    Hi Leith,

    Thanks for the reply. However, when I change the dates in my computer to be less than the 15th day, it still asks for a password. I guess what I'm asking is how to protect a workbook when it is opened using VBA.

    ActiveWorkbook.Password = "test"MyDate = Date

    Thanks for all the help.

+ 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