• change passwords (xp/2003)

    Author
    Topic
    #432241

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1013534

      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.

      • #1013538

        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

        • #1013541

          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?

          • #1014332

            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

            • #1014337

              Try this – change the path as needed, and the passwords of course.

              Sub ProcessDocuments()
              ' Modify as needed, but keep trailing backslash
              Const strPath = "C:Docs"

              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

    Viewing 0 reply threads
    Reply To: change passwords (xp/2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: