The Document object has the following several properties related to document protection:
The Protect method protects the 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.
The syntax of the Protect method is:
Type, NoReset, Password)
where the required
Type parameter specifies the protection type for the document. It can be one of the constants in the following enum:
Enum WdProtectionType wdNoProtection = -1 wdAllowOnlyRevisions = 0 wdAllowOnlyComments = 1 wdAllowOnlyFormFields = 2 End Enum
NoReset is related to any form fields on the document. For more on this, refer to the help documentation. Finally, the optional
Password parameter can be set to a string password that subsequently will be required in order to unprotect the document.
Note that if a document is already protected, the Protect method will cause a runtime error, so the document should first be checked by looking at its ProtectionType property, which can assume any of the
WdProtectionType constants described earlier. This is illustrated in the following code:
If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect wdAllowOnlyComments,,"midnight" End If
This method removes protection from the document. However, if the document is not currently protected, this method ...