[UPDATE] AutoRecovery Save (AutoSave) Fires off the DocumentBeforeSave Event in Word


In my previous blog post I discussed a known problem where the BeforeSave event is fired when Word does an automatic Recovery Save (also known as AutoSave). The previous entry described a way to determine whether an AutoSave is happening by using an obscure WordBasic property (added in Word 2007/2010) just for this scenario.

Well, now there is full object model support for making this determination, but ONLY in Word 2013. In a Word 2013 solution in VS2012, you can now call upon a new Document level property to determine if you are in an auto-save or not:

void Application_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
{
    // check to see if we are in
    // and AutoSave
    if (Doc.IsInAutosave)
        return;
    // your code here...
}

Since this is not backwards compatible with Word 2007 and Word 2010, it will not be much use if your project has to support multiple versions. But the good news is that it is there going forward.

2 thoughts on “[UPDATE] AutoRecovery Save (AutoSave) Fires off the DocumentBeforeSave Event in Word

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s