Expand Minimize
This topic has not yet been rated - Rate this topic

Worksheet.ProtectScenarios Property (2007 System)

Gets a value that indicates whether worksheet scenarios are protected.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.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(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);
        }
    }
}
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.