共用方式為


Visio (Document.Saved 屬性)

會指出文件是否有未儲存的變更。 可讀寫。

語法

運算式保存

表達 代表 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 支援與意見反應