Table of contents
TOC
折叠目录
展开目录

DrawingControl.DocumentOpened 事件 (Visio)DrawingControl.DocumentOpened Event (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

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

语法Syntax

专用子_表达式__DocumentOpened( [IVDOCUMENT] 为 ByVal doc )Private Sub expressionDocumentOpened( **_ByVal doc As [IVDOCUMENT]** )

表达式_一个表示DrawingControl对象的变量。_expression A variable that represents a DrawingControl object.

参数Parameters

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

注解Remarks

DocumentOpened事件通常添加到 Microsoft Visio 模板文件 (.vst) 的事件集合。打开现有文档时,将触发该事件的操作。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're using Microsoft Visual Basic or Visual Basic for Applications (VBA), the syntax in this topic describes a common, efficient way to handle events.

如果您想要创建您自己的事件对象,使用添加AddAdvise方法。若要创建一个事件对象,运行加载项,请使用Add方法,应用到事件列表集合。若要创建一个事件对象,该对象接收通知,请使用AddAdvise方法。若要查找您想要创建的事件的事件代码,请参阅事件代码If you want to create your own Event objects, use the Add or AddAdvise method. To create an Event object that runs an add-on, use the Add method as it applies to the EventList collection. To create an Event object that receives notification, use the AddAdvise method. To find an event code for the event you want to create, seeEvent codes.

您可以向应用程序对象、文档集合或文档对象的事件集合添加DocumentOpened事件。前两个是的 straightforward?if 打开或DocumentOpened事件发生在其文档集合或应用程序对象的作用域中创建一个文档。You can add DocumentOpened events to the EventList collection of an Application object, Documents collection, or Document object. 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.

但是,将DocumentOpened事件添加到事件列表集合文档对象的意义只有该事件的操作是visActCodeRunAddon 。在这种情况下,该事件是 persistable?it 可以与文档一起存储。如果打开的文档包含永久事件,则会触发的操作。如果新文档是基于或复制文档包含永久事件, DocumentOpened事件将被复制到新文档,并触发其操作。但是,如果该事件的操作是visActCodeAdvise ,该事件持久并不因此不存储在文档中;因此永远不会被触发。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. 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. 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.

您可以防止运行应用程序对象的EventsEnabled属性的值设置响应激发DocumentCreatedDocumentOpenedDocumentAdded事件和所有事件代码为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 .

© 2018 Microsoft