Table of contents

Documents.BeforeDocumentSaveAs 事件 (Visio)Documents.BeforeDocumentSaveAs Event (Visio)

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

通过使用另存为命令保存文档之前发生。Occurs just before a document is saved by using the Save As command.


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

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


名称Name必需/可选Required/Optional数据类型Data Type说明Description
docdoc必需Required[IVDOCUMENT][IVDOCUMENT]要保存的文档。The document that is going to be saved.


文档保存到本机格式 (例如,VSD 或 VDX) 或非本地格式 (例如,HTM 或 BMP) 时将触发BeforeDocumentSaveAs事件。文档保存到 DWG 和 DXF,DGN 格式时不会触发。若要以编程方式以非本机格式保存文档,必须使用ExportPage对象的方法。注意,在调用SaveAs方法时,Microsoft Visio 将引发第一次的BeforeDocumentSaveAs事件,然后DocumentSavedAs事件。但是,调用的导出方法,激发BeforeDocumentSaveAs事件,但不是DocumentSavedAs事件,其后在SaveAs方法的响应。The BeforeDocumentSaveAs event fires when a document is saved to either a native format (for example, VSD or VDX) or a non-native format (for example, HTM or BMP). It does not fire when a document is saved to DWG, DXF, and DGN formats. To save a document in a non-native format programmatically, you must use the Export method of the Page object. Note that when you call the SaveAs method, Microsoft Visio fires first the BeforeDocumentSaveAs event and then the DocumentSavedAs event. Calling the Export method, however, fires the BeforeDocumentSaveAs event but not the DocumentSavedAs event that follows it in response to the SaveAs method.

BeforeDocumentSaveAs事件是一组EventInfo属性的应用程序对象包含额外信息的事件之一。The BeforeDocumentSaveAs event is one of a group of events for which the EventInfo property of the Application object contains extra information.

如果存储由用户或程序启动因为引发BeforeDocumentSaveAs事件, EventInfo属性将返回以下字符串:If the BeforeDocumentSaveAs event is fired because a save was initiated by a user or a program, the EventInfo property returns the following string:

"/ saveasfile =""/saveasfile="

如果激发因为 Visio 保存打开的文件 (用于自动恢复或以邮件附件的形式包括) 一份EventInfo属性将返回以下字符串之一:If it fires because Visio is saving a copy of an open file (for autorecovery or to include as a mail attachment), the EventInfo property will return one of the following strings:

  • 如果出于恢复目的引发该事件,以这种格式文件中恢复的名称:"/ autosavefile = C:\TEMP~$2VSO2FD.vsd"If the event is fired for autorecovery purposes, the name of a recovery file in this format: "/autosavefile=C:\TEMP~$2VSO2FD.vsd"

  • 如果引发该事件,因为正在进行的文档副本作为邮件附件发送,以这种格式文件中附件的名称:"/ mailfile = C:\TEMP~$2VSO2FD.vsd"If the event is fired because a document copy is being made to send as a mail attachment, the name of an attachment file in this format: "/mailfile=C:\TEMP~$2VSO2FD.vsd"

如果您使用 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.

如果您想要创建您自己的事件对象,使用添加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.

如果正在处理此事件中使用AddAdvise方法通过连接接收的通知的程序, VisEventProcvMoreInfo_参数将指定文档索引:"/ doc = 1"。If you are handling this event from a program that receives a notification over a connection by using the AddAdvise method, the _vMoreInfo argument to VisEventProc designates the document index: "/doc=1".

© 2018 Microsoft