Worksheet.ProtectScenarios Property (2007 System)
Visual Studio 2008
Gets a value that indicates whether worksheet scenarios are protected.
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
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); } } }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.