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.
[…] ← Previous […]
Does Excel have something similar? I can’t find anything. Thanks!