How are the documents protected if not by a password? See
http://www.gmayor.com/Remove_Password.htm
Is the password the same for each document? If so it would be fairly simple
to batch process the folder(s) to open the documents and remove the
passwords. The following macro will open and if necessary apply one or both
passwords to the documents in order to open them and set the passwords to
nul. The documents for which the password is correct are saved to the
TargetFolder which here is an existing sub folder of the original folder
called Temp. You could error trap that too if you want.
Sub BatchRemovePassword()
Dim OpenPwd As String
Dim WritePwd As String
Dim myFile As String
Dim PathToUse As String
Dim TargetPath As String
Dim iFld As Integer
OpenPwd = "password"
WritePwd = "another"
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count > 0 Then
Documents.Close savechanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
TargetPath = PathToUse & "Temp\"
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
On Error GoTo WrongPwd:
Documents.Open FileName:=myFile, _
PasswordDocument:=OpenPwd, _
WritePasswordDocument:=WritePwd
With ActiveDocument
.ReadOnlyRecommended = False
.Password = ""
.WritePassword = ""
End With
ActiveDocument.SaveAs TargetPath & ActiveDocument.Name
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
WrongPwd:
If Err.Number = 5408 Then 'Document is Password-protected and was NOT
Opened
Err.Clear
Resume Next
End If
myFile = Dir$()
Wend
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>