WorksheetBase.ProtectDrawingObjects Property
Visual Studio 2012
Gets a value that indicates whether shapes are protected.
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
The following code example gets the value of the ProtectDrawingObjects property to determine whether shapes on the worksheet are protected. If shapes are unprotected, then the Protect method is called with the DrawingObjects parameter set to true so that shapes are protected.
This example is for a document-level customization.
private void ProtectShapes() { if (!this.ProtectDrawingObjects) { if (DialogResult.Yes == MessageBox.Show("Shapes in this worksheet " + "are not protected. Protect shapes the worksheet?", "Example", MessageBoxButtons.YesNo)) { // Protect shapes, but do not change any // other protection type. this.Protect(true, this.ProtectContents, this.ProtectScenarios, 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.