Share via


Document.Protect(WdProtectionType, Object, Object, Object, Object) Method

Definition

Applies one of several types of protection to the document.

public void Protect (Microsoft.Office.Interop.Word.WdProtectionType Type, ref object NoReset, ref object Password, ref object UseIRM, ref object EnforceStyleLock);
abstract member Protect : Microsoft.Office.Interop.Word.WdProtectionType * obj * obj * obj * obj -> unit
Public Sub Protect (Type As WdProtectionType, Optional ByRef NoReset As Object, Optional ByRef Password As Object, Optional ByRef UseIRM As Object, Optional ByRef EnforceStyleLock As Object)

Parameters

Type
WdProtectionType

The protection type for the specified document. WdProtectionType.

NoReset
Object

false to reset form fields to their default values. true to retain the current form field values if the document is protected. If Type is not wdAllowOnlyFormFields, the NoReset argument is ignored.

Password
Object

The password required to remove protection from the document. (See Remarks below.)

UseIRM
Object

Specifies whether to use Information Rights Management (IRM) when protecting the document from changes.

EnforceStyleLock
Object

Specifies whether formatting restrictions are enforced in a protected document.

Remarks

When a document is protected, users can make only limited changes, such as adding annotations, making revisions, or completing a form. If the document is already protected when you use this method, an exception is thrown.

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.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to