Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Gloucestershire, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change passwords (xp/2003)

    We have about 500 word files in amongst others in several directories with a password which has been compromised and we need to change it. Please, can anyone suggest how we can automate the process?
    Thanks
    Roberta

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

    Re: change passwords (xp/2003)

    If all those documents have the same password, you could do the following:
    - Move all those documents to a single folder that contains no other documents.
    - Create and run a macro that opens each document in turn, and saves it with a new password.
    - Move the documents back to the original folders.

    If moving the documents is not feasible, you'll need some way to distinguish the documents you want to change the password for from other documents in the same folder.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Gloucestershire, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change passwords (xp/2003)

    Unfortunately, without opening each file, I cannot establish which have the password and which have not. Is is possible to open every file in a folder or sub folder and then reject those where the password is incorrect?
    Regards
    Roberta

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

    Re: change passwords (xp/2003)

    The problem is that if you use VBA code to open a document and specify a password, Word will open a document that has no password at all without any indication that the password wasn't necessary. It will only fail if the document has another password than the one provided.
    Do *all* documents in those folders have a password?

  5. #5
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Gloucestershire, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change passwords (xp/2003)

    I have now moved all the files to one folder (there are about 500 - which is why I really don't want to have to open them individually). I know how to write a macro to open a particular file. I can also write a macro to change a password, but I do not know how to automate the process to open them one after another.

    Help!!! Regards Roberta

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

    Re: change passwords (xp/2003)

    Try this - change the path as needed, and the passwords of course.
    <code>
    Sub ProcessDocuments()
    ' Modify as needed, but keep trailing backslash
    Const strPath = "Cocs"

    Dim strFile As String
    Dim doc As Document

    strFile = Dir(strPath & "*.doc")
    Do While Not strFile = ""
    Set doc = Documents.Open(FileName:=strPath & strFile, _
    AddToRecentFiles:=False, PassWordDocument:="oldpassword")
    doc.Password = "newpassword"
    doc.Close Savechanges:=True
    strFile = Dir
    Loop
    End Sub</code>

Posting Permissions

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