_Document.Protect(WdProtectionType, Object, Object, Object, Object) 方法

定义

帮助保护指定的文档不受更改。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)

参数

Type
WdProtectionType

必填。Required. 指定文档的保护类型。The protection type for the specified document. WdProtectionType.WdProtectionType.

NoReset
Object

可选对象Optional Object. 如果为 False,则将窗体域重置为其默认值。False to reset form fields to their default values. 如果为True ,则保留当前的窗体域值(如果指定的文档受保护)。True to retain the current form field values if the specified document is protected. 如果 Type 不是wdAllowOnlyFormFields,则 NoReset 忽略该参数。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. 指定在保护文档不受更改时是否使用信息权限管理(IRM)。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.

注解

如果使用此方法时文档已经过保护,则会发生错误。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.

适用于