Protect Method
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.
expression.Protect(Type, NoReset, Password)
expression Required. An expression that returns one of the objects in the Applies To list.
Type Required The protection type for the specified document. WdProtectionType.
WdProtectionType can be one of these WdProtectionType constants. |
wdAllowOnlyComments |
wdAllowOnlyFormFields |
wdAllowOnlyRevisions |
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.
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"