如果该属性值为 True,则文档或应用程序是由用户创建或打开的。如果该属性值为 False,则文档或应用程序是由其他 Microsoft Office 应用程序用 Open 方法以及 CreateObject 或 GetObject 方法创建或打开的。对于 Document 对象,该属性为 Boolean 类型,可读写;对于 Application 对象,该属性为 Boolean 类型,只读。
如果 Word 对用户为可见的,或用户在 Word 代码模块内调用 Application 或 Document 对象中的 UserControl 属性,则该属性返回 True。
该示例显示活动文档的 UserControl 属性的状态。本示例仅在从装载 Word 对象库的其他 Office 应用程序运行的情况下有效。
Set wd = New Word.Application
Set wdDoc = _
wd.Documents.Open("C:\My Documents\doc1.doc")
If wdDoc.UserControl = True Then
MsgBox "This document was created or opened by the user."
Else
MsgBox "This document was created programmatically."
End If