UnProtect Method

Microsoft Word Visual Basic

UnProtect Method

       

Removes protection from the specified document. If the document isn't protected, this method generates an error.

expression.UnProtect(Password)

expression   Required. An expression that returns a Document object.

Password   Optional Variant. The password string used to protect the document. Passwords are case-sensitive. If the document is protected with a password and the correct password isn't supplied, a dialog box prompts the user for the password.

Example

This example unprotects the active document, using "Blue" as the password. If the document has a password, a dialog box prompts the user for the password.

If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect Password:="Blue"
End If

This example unprotects the active document. Text is inserted, and the document is protected for revisions.

Set aDoc = ActiveDocument
If aDoc.ProtectionType <> wdNoProtection Then 
    aDoc.Unprotect
    Selection.InsertBefore "department six"
    aDoc.Protect Type:=wdAllowOnlyRevisions, Password:="Blue"
End If