InvisibleApp 事件 (Visio)InvisibleApp.DocumentOpened event (Visio)

在打开文档之后,发生此事件。Occurs after a document is opened.


表达式DocumentOpened(doc)expression.DocumentOpened (doc)

_表达式_一个代表**InvisibleApp** 对象的变量。expression A variable that represents an InvisibleApp object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
doc 必需Required [IVDOCUMENT][IVDOCUMENT] 已打开的文档。The document that was opened.


DocumentOpened 事件通常添加到 Microsoft Visio 模板文件 (.vst) 的 EventList 集合中。The DocumentOpened event is often added to the EventList collection of a Microsoft Visio template file (.vst). 每当打开现有文档时,就会触发该事件的操作。The event's action is triggered whenever an existing document is opened.

如果您使用 Microsoft Visual Basic 或 Visual Basic for Applications (VBA),则此主题中的语法描述的是一种通用而有效的事件处理方法。If you are using Microsoft Visual Basic or Visual Basic for Applications (VBA), the syntax in this topic describes a common, efficient way to handle events.

如果要创建自己的Event对象, 请使用**Add** 或**AddAdvise** 方法。If you want to create your own Event objects, use the Add or AddAdvise method.

若要创建可运行加载项的 Event 对象,请使用 Add 方法,因为它适用于 EventList 集合。To create an Event object that runs an add-on, use the Add method as it applies to the EventList collection.

若要创建可接收通知的 Event 对象,请使用 AddAdvise 方法。To create an Event object that receives notification, use the AddAdvise method.

若要查找要创建的事件的事件代码,请参阅事件代码To find an event code for the event that you want to create, see Event codes.

DocumentOpened 事件可以添加到 Application 对象、Documents 集合或 Document 对象的 EventList 集合中。You can add DocumentOpened events to the EventList collection of an Application object, Documents collection, or Document object. 如果在Application对象或—其Documents集合的范围内打开或创建文档, 则前两个是简单的, DocumentOpened事件发生。The first two are straightforward—if a document is opened or created in the scope of the Application object or its Documents collection, the DocumentOpened event occurs.

但是,仅当该事件的操作是 visActCodeRunAddon 时,将 DocumentOpened 事件添加到 Document 对象的 EventList 集合中才有意义。However, adding a DocumentOpened event to the EventList collection of a Document object makes sense only if the event's action is visActCodeRunAddon. 在这种情况下, 事件是—可持久的, 可以随文档一起存储。In this case, the event is persistable—it can be stored with the document. 如果打开的文档包含永久事件,则触发该事件的操作。If the document that contains the persistent event is opened, its action is triggered. 如果新文档基于包含永久事件的文档或是从该文档复制而来,则会将 DocumentOpened 事件复制到新文档中,并触发该事件的操作。If a new document is based on or copied from the document that contains the persistent event, the DocumentOpened event is copied to the new document and its action is triggered. 但是, 如果事件的操作为visActCodeAdvise, 则该事件不是可持久的, 因此不会与文档一起存储;因此, 永远不会触发它。However, if the event's action is visActCodeAdvise, that event is not persistable and therefore is not stored with the document; hence, it is never triggered.

您可以通过设置 Application 对象的 EventsEnabled 属性的值, 阻止代码在DocumentCreatedDocumentOpenedDocumentAdded事件中运行, 并通过设置Application对象的**** 属性的值来触发所有事件。为FalseYou can prevent code from running in response to the DocumentCreated, DocumentOpened, or DocumentAdded event and all events from firing by setting the value of the EventsEnabled property of an Application object to False.

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.