Password Protected Document

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

Guest

I was wondering how to password protect my saved documents...some nosy roommates:
If that was at all possible can you use the same password for every document

Thank You
 
Manda said:
I was wondering how to password protect my saved documents...some
nosy roommates:) If that was at all possible can you use the same
password for every document?

Thank You

Manda

The following macro will password protect all the files in a folder of your
choice. Change the entry 'password' (**in four places**) for the password of
your choice. Enter the path of the folder containing the files. May I
suggest that you create a new folder for your files (by default this uses
the folder c:\test) and *COPY* your documents into it. Run the macro on that
folder, then when you are satisfied that the files are correctly protected
and that you can access them, copy them back over the originals. Do not
forget the password or you will not be able to open any of your documents.

The code is based on the routine shown at :
http://www.mvps.org/word/FAQs/MacrosVBA/BatchFR.htm
If you don't know how to use the macro, see
http://www.gmayor.com/installing_macro.htm


Public Sub PasswordAll()

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

PathToUse = "C:\Test\"

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 = "password"
.WritePassword = "password"
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 = "password"
.WritePassword = "password"
End With
End If
myDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Back
Top