|
Automatically backup Word documents
|
|
|
Contrary to
popular opinion, Word has no integral means of automatically saving the
current document, nor of backing-up the current document. What it does
have is an option to save AutoRecover information after a specific and
configurable interval and an option to save a backup copy of the
previously saved version of the document with the default file
extension of WBK (and although there is no reason to do so, Word also
allows the option to change this extension to the user's choice). This is
not a true backup in as much as it is not a copy of the current version
of the document.
AutoRecover
provides the basis to recover a document (or part of it) in the event of a
system crash, but is somewhat hit or miss and should not be relied upon to
save your bacon. |
|

or in Word 2007

and

|
|
There is a
macro available with Word that will provide an auto save function called
SaveReminder This is also
available for download from this site via the above link.
This provides
options to both remind you to save, or to automatically save either the
current or all open documents. |
|




|
| Save document to two locations |
|
The way to
achieve a true backup is to save the document to two separate locations,
however, because of the way Word creates temporary files in the workspace,
and the unpredictability of the document size, these locations must
never be on removable media - particularly floppy discs. Saving to
such media is one of the main causes of document corruption (and thus loss
of your work!).
You can achieve
a true backup by means of vba, and the following code will do the trick:
Sub SaveToTwoLocations()
Dim strFileA As
String
Dim strFileB As String
Dim strFileC As String
ActiveDocument.Save
strFileA = ActiveDocument.Name
'Define backup
path shown in blue below
strFileB = "D:\My Documents\Word Backup\Backup
" & strFileA
strFileC = ActiveDocument.FullName
ActiveDocument.SaveAs FileName:=strFileB
ActiveDocument.SaveAs FileName:=strFileC
End Sub
If you don't
know how to use macros from web site listings, see the
linked installation information.
This macro is best called from a toolbar button. It cannot, as it stands,
be used to replace the default 'Save' function which it uses itself,
though you could certainly call it from the toolbar icon
or you could
re-assign the CTRL+S keyboard shortcut to the macro.
In my own installation, I have two 'Save' icons (see below). The left is
the original - the right (re-coloured with the customization tools
) calls
the macro.
|
|
Note: |
You could copy this image and paste it to your Word 2000/2003 toolbar command if you
wish.
With
Word 2007, you could add the macro command to your QAT (Quick Access
Toolbar), but you will be limited to the available icons or you can
create an add-in template with a custom toolbar in Word 2000/3
containing the commands you want and save that in the Word 2007 start-up
folder. |
| |


|
| |
The macro uses the FileSave function to save the document, and allow you
to name the document if a new document. The name is then stored and the
document saved to the defined backup location - D:\My Documents\Word
Backup\ in this example - though the code may easily be changed to
reflect your own preference.
Having saved the document to the backup
location, the Word focus is on the backed up version. To correct this,
without the delay of closing and re-opening the required version of the
document, the document is saved again to the original location.
|
| Note: |
This also has the effect of
updating the automatic backup file (filename.WBK) to make that a true
backup, thus you have two backup files if this option has been set. |
| Save a backup and copy to
removable media |
|
|
The following macro is a variation on the version above, inspired by a
question posed in Microsoft's newsgroup forums. A user wanted to backup
his documents to one of two locations - depending on whether it was an
odd or even date - and to copy the document to a flash drive.
The macro
saves the document in its original location then makes a backup in one
of two locations
D:\My Documents\Test\Versions\Odd
or
D:\My Documents\Test\Versions\Even
highlighted in the code in a bold blue
typeface.
The document is then closed and
the file copied to the flash drive - here shown with the drive letter
H: and then finally the original
document is re-opened. You can change the file locations to suit your requirements.
In addition
the backup copies have the month and date of the backup appended to the beginnings
of the filenames. |
| Note: |
This
method could be used to copy to a floppy
drive, however Word documents can have a file size of many megabytes and
the space available on a floppy drive is strictly limited.
If the
disc is available but will not accommodate the file, the filename will
be created and the error routine will activate. This will delete
the corrupt partial file, but will mean that any file with that name,
that previously existed on the removable medium, will be lost. |
| |
Sub CopyToFlash()
Dim strFileA As
String
Dim strFileB As
String
Dim strFlash As
String
Dim strBackupFolder
As String
With ActiveDocument
.Save 'Save the original document
strFileA = ActiveDocument.name
'Store original document name
'Select flash drive letter. Default is H
strFlash = InputBox("Enter Flash Drive Letter", "Flash
Drive", "H")
strFlash = strFlash & strFileA
'Store flash drive filename
' Set backup alternative
folder for odd and even dates
If Even = (Day(Now)
Mod 2) - 1 Then 'It's
an odd date
strBackupFolder = "Odd\"
Else
'It's an even date
strBackupFolder = "Even\"
End If
'Add full path to backup
folder and date to filename
strFileB = "D:\My
Documents\Test\Versions\" _
& strBackupFolder & Format$(Date, "MMM d ") _
& strFileA
.SaveAs FileName:=strFileB 'save
backup in the appropriate folder
.Close 'close the backup document
End With
On Error GoTo oops
'Trap copy error
FileCopy strFileA, strFlash 'Now copy document to
flash drive
Documents.Open strFileA 'Re-open the original
document
End
oops:
If Err.Number = 61
Then 'Flash drive is full error
MsgBox "Disc Full! The partial file created will be
deleted", vbExclamation
Kill strFlash
Else 'Other error
MsgBox "The flash drive is not available",
vbExclamation
End If
Documents.Open strFileA 'Re-open the original document
End Sub |
| Save a copy of the current
document to flash |
| |
The following is a simpler version of the above macro, which merely
copies the active document to a flash drive, subject to the same warning
above relating to the use of floppy media.. |
| |
Sub
SaveACopyToFlash()
Dim strFileA As
String
Dim strFlash As
String
strFlash = InputBox("Enter Flash Drive Letter", "Flash Drive", "H")
With ActiveDocument
.Save 'save the original document
strFileA = .name 'Saved original
document name
strFlash = strFlash & ":\" & strFileA
'Flash drive filename
.Close 'Close the document
End With
On Error GoTo oops
'Error handler for missing flash drive
FileCopy strFileA, strFlash 'Copy source to flash
Documents.Open strFileA
End
oops:
If Err.Number = 61
Then
MsgBox "Disc Full! The partial file created will be deleted",
vbExclamation
Kill strFlash 'Remove the partial file
Else
MsgBox "The flash drive is not available", vbExclamation
End If
Documents.Open strFileA
End Sub
|