Protect Method
Applies To
Document object.
Description
Protects the specified document from changes. When a document is protected, the user can make only limited changes, such as adding annotations, making revisions, or completing a form.
Note If the document is already protected when you use this method, an error occurs.
Syntax
expression.Protect(Type, NoReset, Password)
expression Required. An expression that returns a Document object.
Type Required Long. The protection type for the specified document. Can be one of the following WdProtectionType constants: wdAllowOnlyComments, wdAllowOnlyFormFields, wdAllowOnlyRevisions, or wdNoProtection.
NoReset Optional Variant. False to reset form fields to their default values. True to retain the current form field values if the specified document is protected. If Type isn't wdAllowOnlyFormFields, the NoReset argument is ignored.
Password Optional Variant. The password required to "unprotect" the specified document.
See Also
Protect property, ProtectedForForms property, ProtectionType property, UnProtect method.
Example
This example protects the active document for forms without resetting the contents of the form fields.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
This example protects Monthly Report.doc so that only comments can be added to it. The password "free" is required to unprotect the document.
Set myDoc = Documents("Monthly Report.doc")
myDoc.Protect Type:=wdAllowOnlyComments, Password:="free"