Apply Word Editing Restrictions and Password Protection to Multiple Files
Question details
Apply the same editing restriction and password to multiple Word documents without configuring each file individually.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A user needs to protect many documents with consistent editing restrictions.
- Observed behavior
- Applying the restriction and password manually to each document is time-consuming.
Place copies of the .docx files in one folder and close them in Word. Test the process on a few copies first, choose a password you can retain securely, and confirm that read-only editing restrictions meet your needs.
Batch-protect Word documents with a VBA macro
Use Word for Windows to apply the same read-only editing restriction and password to every unprotected .docx file in a selected folder.
This example restricts editing; it does not encrypt documents or require a password to open them. It skips documents that are already protected or opened as read-only, and it does not process subfolders.
The password is entered in a visible input box. Run macros only when you understand and trust their code.
In desktop Word for Windows, press Alt+F11, then choose Insert > Module in the VBA editor.
Paste this code into the module: Sub BatchRestrictDocuments() Dim picker As Object, folder As String, fileName As String Dim password As String, result As String, report As String Dim completed As Long Set picker = Application.FileDialog(4) picker.Title = "Select the folder containing DOCX files" If picker.Show <> -1 Then Exit Sub folder = picker.SelectedItems(1) password = InputBox("Enter the editing restriction password:") If password = "" Then Exit Sub fileName = Dir(folder & "\*.docx") Do While fileName <> "" If Left$(fileName, 2) <> "~$" Then result = RestrictOneDocument(folder & "\" & fileName, password) If result = "" Then completed = completed + 1 Else report = report & fileName & ": " & result & vbCrLf End If End If fileName = Dir() Loop MsgBox completed & " document(s) protected." & vbCrLf & report End Sub Private Function RestrictOneDocument(filePath As String, password As String) As String Dim doc As Document On Error GoTo Failed Set doc = Documents.Open(FileName:=filePath, AddToRecentFiles:=False) If doc.ReadOnly Then RestrictOneDocument = "Skipped: opened as read-only." ElseIf doc.ProtectionType <> wdNoProtection Then RestrictOneDocument = "Skipped: already protected." Else doc.Protect Type:=wdAllowOnlyReading, Password:=password doc.Save End If doc.Close SaveChanges:=wdDoNotSaveChanges Exit Function Failed: RestrictOneDocument = "Failed: " & Err.Description On Error Resume Next If Not doc Is Nothing Then doc.Close SaveChanges:=wdDoNotSaveChanges End Function
Place the cursor inside BatchRestrictDocuments and press F5. Select the folder of test copies and enter the restriction password when prompted.
Review the completion message for skipped or failed files. Open a processed document and select Review > Restrict Editing to verify the restriction; use Stop Protection and enter the password to confirm it works.

Use a trusted Word batch-processing utility
Use a batch utility when you need a reusable interface rather than maintaining a VBA macro.
Work with Word Documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format support, making it easy to move documents between applications. It does not replace the Word VBA batch process described above.

Frequently Asked Questions
Does the editing restriction password prevent someone from opening the file?
No. The macro sets a password for removing the editing restriction, not for opening the document. In Word, use File > Info > Protect Document > Encrypt with Password when you need an open password.
Will the macro process files in subfolders?
No. The example processes .docx files in the selected folder only. Move test copies into one folder or run the macro separately for each folder.
What happens if a document is already protected?
The macro skips it and lists it in the completion message. To change its protection, open it in Word, select Review > Restrict Editing > Stop Protection, and enter its existing password.
How can I check that a batch-protected document works?
Open a processed file in Word and select Review > Restrict Editing. Try editing the document, then select Stop Protection and enter the password to verify that the restriction can be removed.




