Password protect files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to password protect a whole group of Word files all at one
time with the same password instead of having to open each file and apply
password protection?
 
You can do this with a macro e.g.

Public Sub PasswordAll()

Dim FirstLoop As Boolean
Dim myFile, Password, PathToUse As String
Dim myDoc As Document
Dim Response As Long

PathToUse = "D:\My Documents\Test\Merge\"
sPassword = InputBox("Enter Password")

On Error Resume Next
Documents.Close Savechanges:=wdPromptToSaveChanges
FirstLoop = True
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
If FirstLoop Then
With ActiveDocument
.Password = sPassword
.WritePassword = sPassword
End With
FirstLoop = False

Response = MsgBox("Do you want to process " & _
"the rest of the files in this folder", vbYesNo)
If Response = vbNo Then Exit Sub
Else
With ActiveDocument
.Password = sPassword
.WritePassword = sPassword
End With
End If
myDoc.Close Savechanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

Change the path to that where you have stored the documents.
Practice with *copies* of the documents and set the backup option to be on
the safe side until you are happy this works for you.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top