I am trying to password protect a large quantity of word files using 2010. I have found several macros similar to the following, but none of them seem to work on 2010. To give credit where credit is do this particular macro was posted on several sites by Graham Mayor. Any ideas? Secondly is there any way to do this a have a different password set for each document? Thank you for any help with this!
Public Sub PasswordAll()
Dim FirstLoop As Boolean
Dim myFile As String
Dim sPassword As String
Dim PathToUse As String
Dim myDoc As Document
Dim Response As Long
PathToUse = InputBox(“Path To Use?”, “Path”, “D:My DocumentsTestMerge”)
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