ProtectScenarios Property

WorksheetBase.ProtectScenarios Property

 

Gets a value that indicates whether worksheet scenarios are protected.

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

public bool ProtectScenarios { get; }

Property Value

Type: System.Boolean

true if the worksheet scenarios are protected; otherwise, false.

The following code example gets the value of the ProtectScenarios property to determine whether worksheet scenarios are protected. If scenarios are unprotected, then the Protect method is called with the Scenarios parameter set to true so that scenarios are protected.

This example is for a document-level customization.

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);
        }
    }
}
Return to top
Show:
© 2016 Microsoft