更新:2007 年 11 月
从工作簿中移除保护。如果工作簿不受保护,则此方法无效。
命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v9.0(在 Microsoft.Office.Tools.Excel.v9.0.dll 中)
语法
声明
Public Sub Unprotect ( _
    Password As Object _
)
用法
Dim instance As Workbook
Dim Password As Object
instance.Unprotect(Password)
public void Unprotect(
    Object Password
)
参数
- Password 
 类型:System.Object- 用于取消保护工作簿的密码,区分大小写。如果工作簿未使用密码保护,则忽略此参数。如果对使用密码保护的工作簿省略了此参数,则该方法会失败。 
备注
如果忘记密码,则不能取消保护工作簿。最好将密码及其对应文档名的列表保存在安全的位置。
可选参数
有关可选参数的信息,请参见了解 Office 解决方案中的可选参数。
示例
下面的代码示例使用 Protect 方法在不指定密码保护的情况下保护工作簿结构和工作簿窗口。然后,该示例使用 Unprotect 方法提示用户取消保护工作簿。
此示例针对的是文档级自定义项。
Private Sub WorkbookUnprotect()
    MsgBox("Protecting the workbook.")
    Me.Protect(Structure:=True, Windows:=True)
    If DialogResult.Yes = MessageBox.Show( _
        "Unprotect the workbook?", "Custom Unprotect Dialog", _
        MessageBoxButtons.YesNo) Then
        Me.Unprotect()
    End If
End Sub
private void WorkbookUnprotect()
{
    MessageBox.Show("Protecting the workbook.");
    this.Protect(missing, true, true);
    if (DialogResult.Yes == MessageBox.Show("Unprotect the workbook?",
        "Custom Unprotect Dialog", MessageBoxButtons.YesNo))
    {
        this.Unprotect(missing);
    }
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。