Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Salem, New Hampshire, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password Control (97)

    I need to retain the ability to lock documents, but need to limit the password to the current users network password.

    History:
    Employees have need to lock documents, but when they leave employment, we may no longer have access to corporate documents. But, if we allow them to lock documents, but only use their own password, then we can open up documents after terminations. We could assign each employee a special password to use with Word, but that would require ongoing maintenance with hiring and terminations, so would prefer to use existing network passwords. Passwords are stored in an Access database and could be looked up from there.

    Solution Needed:
    Looking for code that does the following:
    Allows them to select Tools/Protect Document, but will only allow them to enter their current network password (or a special Word password for them). If password entered does not match, then locking document will not be allowed.

    Environment:
    Word97 on Win95 and Win98 workstations.

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

    Re: Password Control (97)

    I don't think that is possible, and if it were, it probably wouldn't be difficult to get around it, but perhaps others will correct me.

    However, password protection in Word 97 is not very strong, I think Open Office will open password-protected documents without even asking for the password, and there are many password-crackers available on the internet, so it shouldn't be a big problem.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Password Control (97)

    As Hans notes, the password protection scheme used for Tools>Protect Document is completely unlike the password that can be required to open the document. The document protection password can be removed using this sequence of events in Word, if you do not have OpenOffice.org or StarOffice handy.
    1. <LI>Open the document.
      <LI>File>Save As..., and choose RTF format. (For safety's sake, do not overwrite your original!)
      <LI>Close the document and open the RTF. The document is protected, but the password is gone.
      <LI>File>Save As..., and choose Word Document (.doc) format. Just in case anything was lost in the round-trip conversion, it is best not to overwrite your original.
    Note: I haven't tried that in Word 2003, but it works in Word 2000-2002. I really can't recall for Word 97.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Password Control (97)

    This shouldn't be too difficult to do. The macro only really needs three parts - here are two of them

    1. Find out the current username
    <pre>sUsername = Environ("Username")</pre>


    2. Query the database to return the password associated with that username - I don't have the code handy for this at the moment but it is not too difficult to find samples on the web

    3. Use the returned password to add a password to the file
    <pre>If ActiveDocument.WriteReserved = False Then
    With ActiveDocument
    .ReadOnlyRecommended = False
    .SaveFormsData = False
    .SaveSubsetFonts = False
    .Password = sSecret
    .WritePassword = ""
    End With
    Application.DefaultSaveFormat = ""
    ActiveDocument.Save
    MsgBox "Document is protected with your usual password"
    Else
    With ActiveDocument
    .ReadOnlyRecommended = False
    .SaveFormsData = False
    .SaveSubsetFonts = False
    .Password = ""
    .WritePassword = ""
    End With
    Application.DefaultSaveFormat = ""
    ActiveDocument.Save
    MsgBox "Document is not protected."
    End If</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    Lounger
    Join Date
    Apr 2002
    Location
    Salem, New Hampshire, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password Control (97)

    Thanks Andrew.

    This looks like what I was looking for. I will work on this over rhe weekend and get back with results.

    It appears that I have understated the problem however. We also need the same type of control to be used when using Options/Save/ Password to Open and Modify. I suspect the same approach will be good, just need to get the name of the objects used there also.

    Thanks again for pointing me in the right direction.

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Password Control (97)

    You will notice in the code I gave you there are two password values - I think .WritePassword is the one you are looking for. If this is an empty string then there is no password.

    To find code which links to the database to extract the password value, here are some useful keywords to search on
    CreateWorkspace OpenRecordset FilterField Set
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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