Document.ProtectionType 属性 (2007 system)

更新:2007 年 11 月

获取文档的保护类型。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v9.0(在 Microsoft.Office.Tools.Word.v9.0.dll 中)

语法

声明
Public ReadOnly Property ProtectionType As WdProtectionType
用法
Dim instance As Document
Dim value As WdProtectionType

value = instance.ProtectionType
public WdProtectionType ProtectionType { get; }

属性值

类型:Microsoft.Office.Interop.Word.WdProtectionType

返回的保护类型可以是下列 WdProtectionType 常数之一:wdAllowOnlyCommentswdAllowOnlyFormFieldswdAllowOnlyReadingwdAllowOnlyRevisionswdNoProtection

示例

下面的代码示例检查是否已为文档设置保护功能。如果未设置,该代码将设置保护功能以便仅允许使用注释。

此示例针对的是文档级自定义项。

Private Sub DocumentProtectionType()
    If Me.ProtectionType = Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection Then
        Me.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyComments)
    End If
End Sub 
private void DocumentProtectionType()
{
    if (this.ProtectionType == Microsoft.Office.Interop.
        Word.WdProtectionType.wdNoProtection)
    {
        this.Protect(Microsoft.Office.Interop.Word.
            WdProtectionType.wdAllowOnlyComments, 
            ref missing, ref missing, ref missing,
            ref missing);
    }
}

权限

另请参见

参考

Document 类

Document 成员

Microsoft.Office.Tools.Word 命名空间