Expand Minimize

_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)

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

Parameters

Type
Type: Microsoft.Office.Interop.Word.WdProtectionType

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

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.

Show:
© 2014 Microsoft