Proper auto-save for Word

This blog died when I took my new job, and now that I've settled in properly, it's time to resurrect it.

On my wife's main work machine, I set Windows Update to download any patches automatically and install them without any prompting from the user - basically, fire-and-forget mode. The problem is that she's working on her MBA dissertation, and a couple of days ago she worked from 10 am to bed-time without saving her work. Her Windows Update kicked-in at 3 am the next morning, downloaded and installed the latest critical patches ... and then re-booted the machine.

AutoRecover was on, but doesn't work unless it believes that Word 2003 crashed in some way. Windows Update obviously closed Word without causing it to crash, so the AutoRecover information was dropped. Auto-backup worked fine, but that just takes a copy of your document when you open it, so it wasn't any use in this situation either.

So that was about 10 hours' of work up the swanee...

So with the help of Mr Google and a little thought, I cobbled together some VBA code to save the active Word document every 5 minutes. The trouble with this approach is that if any corruption happens during the Save, your document is stuffed anyway. So I added some extra code to save a copy of the active document to an audit folder (currently "C:\WordAudit\") at the same time as the normal save is done. The audit document name has the audit date and time added in the format " yyyymmdd hhmmss".

So every 5 minutes, "Dissertation.doc" (for example) is saved in the audit folder as "Dissertation 20050619 183004.doc", before being saved as its original path and name.

I've added a check that the active document actually needs saving, that it isn't a completely new document, that it hasn't been opened in read-only mode, and that it isn't a Sharepoint document. You don't want to save Sharepoint documents dozens of times because that creates an enormous revision history. Finally, I also ran the same Save procedure when the user closes the active document - this prevents that annoying dialog asking if you want to save your document.

To use this VBA code for your Word documents, simply use the Word Visual Basic editor to add it as a new module in your template.