共用方式為


WorkbookBase.ProtectWindows Property

Definition

Gets a value that indicates whether the windows of the workbook are protected.

public:
 property bool ProtectWindows { bool get(); };
public bool ProtectWindows { get; }
member this.ProtectWindows : bool
Public ReadOnly Property ProtectWindows As Boolean

Property Value

true if the windows of the workbook are protected; otherwise, false.

Examples

The following code example uses the Protect method to protect the structure of the workbook and workbook windows, but without specifying password protection. The example then checks the values of the ProtectStructure and ProtectWindows properties to verify that this protection is set.

This example is for a document-level customization.

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.");
    }
}
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

Applies to