You would have to open them individually and save the result. You could do
this with a batch processing macro, if you put the files into a folder for
that purpose first. The following macro should do that. Try it out with a
few files first to ensure that you can re-open them using the password.
ALWAYS work with copies and DO NOT delete the originals until you are sure
that you can open the password protected files.
DON'T FORGET THE PASSWORD!!!!!
Public Sub PasswordAll()
Dim strFileName As String
Dim sPassword As String
Dim bPassword As String
Dim strPath As String
Dim oDoc As Document
Dim bBack As Boolean
Dim Response As Long
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Add Password"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
OpenPass:
sPassword = InputBox("Enter Password", "Password to Open")
bPassword = InputBox("Re-enter Password", "Password to Open")
If sPassword <> bPassword Then
MsgBox "The password and check do not match", _
vbCritical, "Password Error!"
GoTo OpenPass
End If
On Error Resume Next
Documents.Close SaveChanges:=wdPromptToSaveChanges
bBack = Options.CreateBackup
Options.CreateBackup = False
strFileName = Dir$(strPath & "*.doc")
While strFileName <> ""
Set oDoc = Documents.Open(strPath & strFileName)
With oDoc
.Password = sPassword
.SaveAs .FullName, AddtoRecentFiles:=False
.Close SaveChanges:=wdDoNotSaveChanges
End With
strFileName = Dir$()
Wend
Options.CreateBackup = bBack
End Sub
http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>