Document.Saved プロパティ (Visio)

図面に未保存の変更があるかどうかを示します。 値の取得と設定が可能です。

構文

保存

Document オブジェクトを表す変数。

戻り値

Boolean

注釈

ドキュメントの Saved プロパティを True に設定する場合は注意が必要 です[保存済み] プロパティを True に設定し、ユーザーまたは別のプログラムを閉じる前にドキュメントに変更を加えた場合、それらの変更は失われます。Microsoft Visio はドキュメントを保存するためのプロンプトを提供しません。

埋め込みまたはリンクされた OLE オブジェクトを含む図面の場合は、図面の Saved プロパティが True に設定されていても、未保存として値を返す場合があります。

この VBA (Microsoft Visual Basic for Applications) マクロは、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 のサポートおよびフィードバックを参照してください。