Freigeben über


WorksheetBase.ProtectScenarios-Eigenschaft

Ruft einen Wert ab, der angibt, ob Arbeitsblattszenarien geschützt sind.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property ProtectScenarios As Boolean
    Get
public bool ProtectScenarios { get; }

Eigenschaftswert

Typ: System.Boolean
true, wenn Arbeitsblattszenarien geschützt sind; andernfalls false.

Beispiele

Im folgenden Codebeispiel wird der Wert der ProtectScenarios-Eigenschaft abgerufen, um festzustellen, ob Arbeitsblattszenarien geschützt sind. Wenn Szenarien nicht geschützt sind, wird die Protect-Methode mit dem Scenarios-Parameter aufgerufen. Dieser ist auf true festgelegt, sodass Szenarien geschützt sind.

Dieses Beispiel bezieht sich auf eine Anpassung auf Dokumentebene.

Private Sub SetScenarioProtectionOn()
    If Not Me.ProtectScenarios Then
        If DialogResult.Yes = MessageBox.Show("Scenario protection is " & _
            "turned off. Turn on scenario protection?", "Example", _
            MessageBoxButtons.YesNo) Then

            ' Enable scenario protection, but do not change 
            ' any other protection type.
            Me.Protect(DrawingObjects:=Me.ProtectDrawingObjects, _
                Contents:=Me.ProtectContents, Scenarios:=True, _
                UserInterfaceOnly:=Me.ProtectionMode, _
                AllowFormattingCells:=Me.Protection.AllowFormattingCells, _
                AllowFormattingColumns:=Me.Protection.AllowFormattingColumns, _
                AllowFormattingRows:=Me.Protection.AllowFormattingRows, _
                AllowInsertingColumns:=Me.Protection.AllowInsertingColumns, _
                AllowInsertingRows:=Me.Protection.AllowInsertingRows, _
                AllowInsertingHyperlinks:=Me.Protection.AllowInsertingHyperlinks, _
                AllowDeletingColumns:=Me.Protection.AllowDeletingColumns, _
                AllowDeletingRows:=Me.Protection.AllowDeletingRows, _
                AllowSorting:=Me.Protection.AllowSorting, _
                AllowFiltering:=Me.Protection.AllowFiltering, _
                AllowUsingPivotTables:=Me.Protection.AllowUsingPivotTables)
        End If
    End If
End Sub
private void SetScenarioProtectionOn()
{
    if (!this.ProtectScenarios)
    {
        if (DialogResult.Yes == MessageBox.Show("Scenario protection is " +
            "turned off. Turn on scenario protection?", "Example",
            MessageBoxButtons.YesNo))
        {
            // Enable scenario protection, but do not change 
            // any other protection type.
            this.Protect(missing, this.ProtectDrawingObjects,
                this.ProtectContents, true, this.ProtectionMode, 
                this.Protection.AllowFormattingCells,
                this.Protection.AllowFormattingColumns,
                this.Protection.AllowFormattingRows,
                this.Protection.AllowInsertingColumns,
                this.Protection.AllowInsertingRows,
                this.Protection.AllowInsertingHyperlinks,
                this.Protection.AllowDeletingColumns,
                this.Protection.AllowDeletingRows,
                this.Protection.AllowSorting,
                this.Protection.AllowFiltering,
                this.Protection.AllowUsingPivotTables);
        }
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

WorksheetBase Klasse

Microsoft.Office.Tools.Excel-Namespace