Freigeben über


DocumentBase.ProtectionType-Eigenschaft

Ruft den Schutztyp für das Dokument ab.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property ProtectionType As WdProtectionType
public WdProtectionType ProtectionType { get; }

Eigenschaftswert

Typ: Microsoft.Office.Interop.Word.WdProtectionType
Bei dem zurückgegebenen Schutztyp kann es sich um eine der folgenden WdProtectionType-Konstanten handeln: wdAllowOnlyComments, wdAllowOnlyFormFields, wdAllowOnlyReading, wdAllowOnlyRevisions oder wdNoProtection.

Beispiele

Im folgenden Codebeispiel wird überprüft, ob für das Dokument Schutz festgelegt wurde. Wenn nicht, legt der Code Schutz fest, sodass nur Kommentare zugelassen sind. Wenn Sie dieses Beispiel verwenden möchten, führen Sie es von der ThisDocument-Klasse in einem Projekt auf Dokumentebene aus.

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

.NET Framework-Sicherheit

Siehe auch

Referenz

DocumentBase Klasse

Microsoft.Office.Tools.Word-Namespace