apply a common password for multiple word documents

K

kesk

Dear All,

I have a series of documents, which i want to protect with passwords.
Opening individual files and then entering a password is going to be
difficult since i have 100s of them. Is it possible ?

Any idea would be welcome.

kesk
 
G

Graham Mayor

Put copies of the documents you want to protect in a separate folder and run
the following macro on that folder having first set the required password in
the line
strPassword = "password"
Ensure that you can open the documents with that password before removing
the original unprotected versions.
Don't forget the password!
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Sub BatchSetPassword()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer
Dim strPassword As String
strPassword = "password"

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
myFile = Dir$(PathToUse & "*.do?")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
MyDoc.Password = strPassword
MyDoc.Close savechanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top