Share via


WorkbookBase.ProtectWindows 屬性

取得值,指出活頁簿視窗是否受到保護。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property ProtectWindows As Boolean
public bool ProtectWindows { get; }

屬性值

型別:System.Boolean
如果活頁簿視窗受到保護則為 true,否則為 false。

範例

下列程式碼範例使用 Protect 方法,保護活頁簿和活頁簿視窗的結構,但不設定密碼保護。 然後此範例檢查 ProtectStructure 和 ProtectWindows 屬性的值,驗證是否已設定保護。

這是示範文件層級自訂的範例。

Private Sub ProtectWorkbook()
    Me.Protect(Structure:=True, Windows:=True)

    If Me.ProtectStructure Then
        MsgBox("You cannot add, delete or change the location " & _
            "of sheets in this workbook.")
    End If

    If Me.ProtectWindows Then
        MsgBox("You cannot arrange windows in this workbook.")
    End If
End Sub
private void ProtectWorkbook()
{
    this.Protect( true, true);

    if (this.ProtectStructure)
    {
        MessageBox.Show("You cannot add, delete or change the location " +
            "of sheets in this workbook.");
    }

    if (this.ProtectWindows)
    {
        MessageBox.Show("You cannot arrange windows in this workbook.");
    }
}

.NET Framework 安全性

請參閱

參考

WorkbookBase 類別

Microsoft.Office.Tools.Excel 命名空間