_Document.Protect Method

Helps to protect the specified document from changes. When a document is protected, users can make only limited changes, such as adding annotations, making revisions, or completing a form.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)


Sub Protect ( _
    Type As WdProtectionType, _
    ByRef NoReset As Object, _
    ByRef Password As Object, _
    ByRef UseIRM As Object, _
    ByRef EnforceStyleLock As Object _
Dim instance As _Document
Dim Type As WdProtectionType
Dim NoReset As Object
Dim Password As Object
Dim UseIRM As Object
Dim EnforceStyleLock As Object

instance.Protect(Type, NoReset, Password, _
    UseIRM, EnforceStyleLock)
void Protect(
    WdProtectionType Type,
    ref Object NoReset,
    ref Object Password,
    ref Object UseIRM,
    ref Object EnforceStyleLock


  • NoReset
    Type: System.Object%
    Optional Object. False to reset form fields to their default values. True to retain the current form field values if the specified document is protected. If Type isn't wdAllowOnlyFormFields, the NoReset argument is ignored.
  • Password
    Type: System.Object%
    Optional Object. The password required to remove protection from the specified document. (See Remarks below.)
  • UseIRM
    Type: System.Object%
    Optional Object. Specifies whether to use Information Rights Management (IRM) when protecting the document from changes.
  • EnforceStyleLock
    Type: System.Object%
    Optional Object. Specifies whether formatting restrictions are enforced in a protected document.


If the document is already protected when you use this method, an error occurs.

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

See Also


_Document Interface

_Document Members

Microsoft.Office.Interop.Word Namespace