WorksheetBase.ProtectScenarios (Propiedad)

Obtiene un valor que indica si los escenarios de la hoja de cálculo están protegidos.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel.v4.0.Utilities (en Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Sintaxis

'Declaración
Public ReadOnly Property ProtectScenarios As Boolean
public bool ProtectScenarios { get; }

Valor de propiedad

Tipo: System.Boolean
true si los escenarios de la hoja de cálculo están protegidos; de lo contrario, false.

Ejemplos

El ejemplo de código siguiente obtiene el valor de la propiedad ProtectScenarios para determinar si los escenarios de la hoja de cálculo están protegidos.Si los escenarios no están protegidos, se llama al método Protect con el parámetro Scenarios establecido en true para proteger los escenarios.

Se trata de un ejemplo para una personalización en el nivel del documento.

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(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);
        }
    }
}

Seguridad de .NET Framework

Vea también

Referencia

WorksheetBase Clase

Microsoft.Office.Tools.Excel (Espacio de nombres)