Edit

Share via


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

Definition

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.

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

Required. The protection type for the specified document. WdProtectionType.

NoReset
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
Object

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

UseIRM
Object

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

EnforceStyleLock
Object

Optional Object. Specifies whether formatting restrictions are enforced in a protected document.

Remarks

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.

Applies to