This documentation is archived and is not being maintained.

Saved Property [Visio 2003 SDK Documentation]

Office 2003

Determines whether a document has any unsaved changes.

boolRet = object.Saved

object.Saved = boolExpression

boolRet     Boolean. True if the document has no unsaved changes; otherwise, False.

object     Required. An expression that returns a Document object.

boolExpression     Required Boolean. True to indicate the document is saved; False to indicate unsaved changes.

Version added



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 Office Visio does not provide a prompt to save the document.

A document that contains embedded or linked OLE objects may report itself as unsaved even if the document's Saved property is set to True.


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. 

    '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 
    Set vsoDocument1 = Documents.Open("path\filename.vsd") 

End Sub

Applies to | Document object