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

Document.Saved 属性 (Visio)Document.Saved Property (Visio)

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

指示文档是否有未保存的更改。可读写。Indicates whether a document has any unsaved changes. Read/write.

语法Syntax

表达式保存expression . Saved

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

返回值Return Value

BooleanBoolean

注解Remarks

在将文档的Saved属性设置为True时要格外小心。如果将Saved属性设置为True ,用户或另一个程序,更改了文档关闭之前,这些更改将会丢失 — Microsoft Visio 不提供保存该文档的提示。Use caution when setting the Saved property for a document to True . If you set the Saved property to True and a user, or another program, makes changes to the document before it is closed, those changes will be lost—Microsoft Visio does not provide a prompt to save the document.

包含嵌入或链接 OLE 对象的文档,可能会报告本身为未保存即使文档的Saved属性设置为TrueA document that contains embedded or linked OLE objects may report itself as unsaved even if the document's Saved property is set to True .

示例Example

(VBA) 宏此 Microsoft Visual Basic for Applications 演示如何使用已保存属性可确定文档是否有任何未保存的更改。它还演示如何将Saved属性设置。运行此宏之前,应先将_路径_更改为您要在其中保存该绘图,位置,并将_文件名_更改为您想要分配文件的名称。This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Saved property to determine whether a document has any unsaved changes. It also shows how to set the Saved property. Before running this macro, change path to the location where you want to save the drawing, and change filename to the name you'd like to assign the file.


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
© 2018 Microsoft