UnProtect 方法

       

清除对指定文档的保护。如果对文档没有加以保护,则此方法会导致出错。

expression.UnProtect(Password)

expression   必需。该表达式返回一个 Document 对象。

Password   Variant 类型,可选。用于保护文档的口令字符串。口令区分大小写。如果用户在使用一篇设置有口令的文档时没有提供正确的口令,就会显示一个对话框,提示用户输入口令。

示例

本示例解除对活动文档的保护,并以“Blue”为密码。如果文档有密码,则显示一个对话框提醒用户输入密码。

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

本示例解除对活动文档的保护。然后插入文本并对文档进行修订保护。

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