Worksheet.Unprotect 方法 (2007 system)

更新: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 Worksheet
Dim Password As Object

instance.Unprotect(Password)
public void Unprotect(
    Object Password
)

参数

  • Password
    类型:System.Object

    用于取消保护工作表的密码,区分大小写。如果工作表未使用密码保护,则忽略此参数。如果对有密码保护的工作表忽略此参数,则将提示您输入密码。

备注

如果忘记密码,则无法取消对工作表的保护。最好将密码及其对应文档名的列表保存在安全的位置。

可选参数

有关可选参数的信息,请参见了解 Office 解决方案中的可选参数

示例

下面的代码示例确定当前工作表的单元格内容是否受保护。如果单元格内容受保护,则该示例提示用户使用 Unprotect 方法取消对单元格内容的保护。

此示例针对的是文档级自定义项。

Private Sub PromptUnprotectWorksheet()
    If Me.ProtectContents Then
        If DialogResult.Yes = MessageBox.Show("The worksheet is protected. " & _
            "Unprotect the worksheet?", "Example", MessageBoxButtons.YesNo) Then
            Me.Unprotect()
        End If
    End If
End Sub
private void PromptUnprotectWorksheet()
{
    if (this.ProtectContents)
    {
        if (DialogResult.Yes == MessageBox.Show("The worksheet is protected. " +
            "Unprotect the worksheet?", "Example",
            MessageBoxButtons.YesNo))
        {
            this.Unprotect(missing);
        }
    }
}

权限

另请参见

参考

Worksheet 类

Worksheet 成员

Microsoft.Office.Tools.Excel 命名空间