Compartir a través de


WorksheetBase.ProtectDrawingObjects (Propiedad)

Obtiene un valor que indica si las formas están protegidas.

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 ProtectDrawingObjects As Boolean
public bool ProtectDrawingObjects { get; }

Valor de propiedad

Tipo: System.Boolean
true si las formas están protegidas; de lo contrario, false.

Ejemplos

El ejemplo de código siguiente obtiene el valor de la propiedad ProtectDrawingObjects para determinar si las formas de la hoja de cálculo están protegidas.Si las formas no están protegidas, se llama al método Protect con el parámetro DrawingObjects establecido en true para proteger las formas.

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

    Private Sub ProtectShapes()
        If Not Me.ProtectDrawingObjects Then
            If DialogResult.Yes = MessageBox.Show("Shapes in this worksheet " & _
                "are not protected. Protect shapes the worksheet?", "Example", _
                MessageBoxButtons.YesNo) Then

                ' Protect shapes, but do not change any 
                ' other protection type.
                 Me.Protect(DrawingObjects:=True, _
                    Contents:=Me.ProtectContents, Scenarios:=Me.ProtectScenarios, _
                    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 'ProtectShapes

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

Seguridad de .NET Framework

Vea también

Referencia

WorksheetBase Clase

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