Document.ProtectionType, propriété (System 2007)

Mise à jour : novembre 2007

Obtient le type de protection pour le document.

Espace de noms :  Microsoft.Office.Tools.Word
Assembly :  Microsoft.Office.Tools.Word.v9.0 (dans Microsoft.Office.Tools.Word.v9.0.dll)

Syntaxe

Public ReadOnly Property ProtectionType As WdProtectionType

Dim instance As Document
Dim value As WdProtectionType

value = instance.ProtectionType
public WdProtectionType ProtectionType { get; }

Valeur de propriété

Type : Microsoft.Office.Interop.Word.WdProtectionType

Le type de protection retourné peut être l'une des constantes WdProtectionType suivantes : wdAllowOnlyComments, wdAllowOnlyFormFields, wdAllowOnlyReading, wdAllowOnlyRevisions ou wdNoProtection.

Exemples

L'exemple de code suivant vérifie si la protection a été définie pour le document. Si tel n'est pas le cas, le code définit une protection qui n'autorise que les commentaires.

Cet exemple illustre une personnalisation au niveau du document.

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

Autorisations

Voir aussi

Référence

Document, classe

Membres Document

Microsoft.Office.Tools.Word, espace de noms