DocumentBase.ProtectionType Property

 

Gets the protection type for the document.

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

public WdProtectionType ProtectionType { get; }

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);
    }
}
Return to top
Show: