Document.Saved 属性 (Visio)

指示文档是否有未保存的更改。 读/写。

语法

表达式保存

表达 一个代表 Document 对象的变量。

返回值

布尔值

备注

将文档的 Saved 属性设置为 True 时要小心。 如果将 Saved 属性设置为 True,当一个用户或另一个程序在该文档关闭前对其进行更改时,这些更改将丢失 — Microsoft Visio 不会提示保存文档。

即使包含嵌入或链接 OLE 对象的文档的 Saved 属性设置为 True,该文档也可能报告自己未被保存。

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 Saved 属性确定文档是否有未保存的更改。 该宏还显示如何设置 Saved 属性。 运行此宏之前,请将 path 更改为要保存绘图的位置,并且将 filename 更改为要指定给文件的名称。

 
Public Sub Saved_Example() 
 
 Dim vsoDocument1 As Visio.Document 
 Dim vsoDocument2 As Visio.Document 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 
 Set vsoPage = ThisDocument.Pages(1) 
 Set vsoShape = vsoPage.DrawOval(2.5, 7, 3.5, 9) 
 
 'Use the SaveAs method to save the document for the first time. 
 ThisDocument.SaveAs "path\filename .vsd" 
 
 'Use the Saved property to verify that the document was saved. 
 'Saved returns True (-1). 
 Debug.Print ThisDocument.Saved 
 
 'Force a change to the document by adding a shape. 
 Set vsoShape = vsoPage.DrawOval(4, 7, 5, 9) 
 
 'Use the Saved property to verify that the document changed 
 'since the last time is was saved. 
 'Saved returns False (0) 
 Debug.Print ThisDocument.Saved 
 
 'Use the Save method to save any new changes. 
 ThisDocument.Save 
 
 'Use the Saved property again to verify that 
 'the document was saved. Saved returns True (-1). 
 Debug.Print ThisDocument.Saved 
 
 'The Saved property can also be set. For example, change 
 'the document again so that the Saved property becomes False. 
 Set vsoShape = vsoPage.DrawRectangle(1, 1, 7, 7) 
 
 'Set the Saved property to True. 
 'Setting the Saved property to True does not save the document. 
 ThisDocument.Saved = True 
 
 'Close the document and then reopen it. Note that 
 'the rectangle was not saved. 
 Set vsoDocument1 = ThisDocument 
 vsoDocument1.Close 
 Set vsoDocument1 = Documents.Open("path\filename .vsd") 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。