Compartilhar via


DocumentBase.ProtectionType Property

Definition

Gets the protection type for the document.

public:
 property Microsoft::Office::Interop::Word::WdProtectionType ProtectionType { Microsoft::Office::Interop::Word::WdProtectionType get(); };
public Microsoft.Office.Interop.Word.WdProtectionType ProtectionType { get; }
member this.ProtectionType : Microsoft.Office.Interop.Word.WdProtectionType
Public ReadOnly Property ProtectionType As WdProtectionType

Property Value

The returned protection type can be one of the following WdProtectionType constants: wdAllowOnlyComments, wdAllowOnlyFormFields, wdAllowOnlyReading, wdAllowOnlyRevisions, or wdNoProtection.

Examples

The following code example checks whether protection has been set for the document. If not, the code sets protection to allow only comments. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentProtectionType()
{
    if (this.ProtectionType == Microsoft.Office.Interop.
        Word.WdProtectionType.wdNoProtection)
    {
        this.Protect(Microsoft.Office.Interop.Word.
            WdProtectionType.wdAllowOnlyComments, 
            ref missing, ref missing, ref missing,
            ref missing);
    }
}
Private Sub DocumentProtectionType()
    If Me.ProtectionType = Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection Then
        Me.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyComments)
    End If
End Sub 

Applies to