다음을 통해 공유


WorksheetBase.ProtectDrawingObjects 속성

도형이 보호되어 있는지 여부를 나타내는 값을 가져옵니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel.v4.0.Utilities(Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

구문

‘선언
Public ReadOnly Property ProtectDrawingObjects As Boolean
public bool ProtectDrawingObjects { get; }

속성 값

형식: System.Boolean
모양이 보호되어 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 ProtectDrawingObjects 속성의 값을 가져와 워크시트의 도형이 보호되어 있는지 여부를 확인합니다.도형이 보호되어 있지 않으면 DrawingObjects 매개 변수를 true로 설정하여 Protect 메서드를 호출함으로써 도형을 보호합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

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

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

WorksheetBase 클래스

Microsoft.Office.Tools.Excel 네임스페이스