In a previous post I wrote about a change in Word’s behavior: Even if the user chooses “Don’t save” when closing a Word document, the DocumentBeforeSave event triggers.

We’ve been thinking this is a bug, but it turns out that it’s not – it’s by design.

Most of us are familiar with AutoSave in Office, which takes place at pre-determined intervals (settings in File/Options/Save). These AutoSave files have the extension *.asd. The primary purpose is to minimize data loss in case Word or the computer crashes.

But we all know there’s another cause of data loss: user error. I’m sure all of us, at some time or another, have closed a document without saving our work and later regretted it bitterly. Word 2013 introduces two extensions to the AutoSave feature to further minimize data loss:

  • Recovery of unsaved documents
  • Versions

Recovery of unsaved documents is triggered when the user closes a new document without ever having saved it. The content is saved as a *.asd file and can be accessed through File/Info/Versions/Manage Versions. After a certain number of days, these files are automatically deleted. This article shows how recover an unsaved document.

Versions are created when Word performs an AutoSave during editing of documents that have been saved previously. These are also *.asd files, but are stored by default in a different location than the backups of unsaved documents. During a session, all the autosaves are listed in File/Info/Versions; if you close the file without saving, then re-open it, only the last autosaved version is listed.

Clicking an entry opens the version; a message bar offers you the options of comparing the autosaved version with the one in the opened document or restoring the opened document using the autosaved information.

Compare/Restore versions

If you choose Restore, the content of the opened file is changed to match that of the autosaved version.

Compare displays in three tiled windows the original, the autosaved version and the proposed restored version with differences marked as revisions, together with the Revsions task pane listing the differences. You can edit the proposal and save it as a separate file, if you wish. Or you can close these windows and use the Restore button.

2013_Versions_2

This is great for the user, but presents the developer with a problem: how to know whether a Save was triggered by the user, or by the AutoSave functionality. With the introduction of AutoSave triggering when closing a document that has never been saved, the issue becomes even more critical. Up until Word 2013 we could rely on re-purposing the Save and Save As commands. But with their integration into the Backstage this was no longer possible.

For this reason, a new property for the Document object has been added to the Word 2013 object model: IsInAutoSave. It is meant to be used within the DocumentBeforeSave event. You can use it to test whether the event was triggered by an AutoSave and perform actions as appropriate.

Private Sub oApp_DocumentBeforeSave( _
            ByVal Doc As Document, _
            SaveAsUI As Boolean, _
            Cancel As Boolean)
    If Not Doc.IsInAutosave Then
        'do stuff
    Else
        'do something else, or nothing   
    End If
End Sub
One Response to “Word 2013: AutoSave and the new property IsInAutoSave”
  1. Anderson Rissardi says:

    Hi,

    This property realy helps, but is only for Word 2013.

    Anyone know how to do this in word 2010?

    Tankyou!

  2.  
Leave a Reply