|
|
Advertisement |
 |
PPC
>
Computing
Guides >
How do I...?
How To Backup Files Using Word
Here’s one of the best automated backup tips
ever! All you need is Microsoft Word 97 or later, a second disk
drive, and a little know-how courtesy of Dave Cook.
File
backups are an essential part of computer maintenance. Yet many of
us find ourselves simply too busy (or too lazy) to backup our data
on a regular basis. It’s a crazy situation, since the data recorded
on our computer is often more valuable than the cost of a new drive.
So here’s a failsafe way to backup documents (and
other important data) to another hard disk every time you exit
Microsoft Word. It’s not as safe as storing backup media offsite, of
course. But it’s immeasurably better than not creating a backup in
the first place.
Most applications will let you save files to a
folder of your choice, so get into the habit of saving all your
important data to one folder, such as the My Documents folder. Then
you’ll need to create a simple macro using Word’s VBA editor, and a
DOS batch file using a text editor such as Windows Notepad.
When you’re finished, you’ll be able to backup the
contents of the My Documents folder to another drive every time you
close Word. All that’s required on your part is one extra click of
the mouse button. As an added bonus, the backup will be incremental:
after the initial backup, only changed files will overwrite older
versions stored on the second drive.
Batch File
We’ll begin with a couple of batch file examples.
The first example assumes the files to be backed up are stored in a
folder called DATA on drive C:.
To create a batch file that will backup these files
(and subfolders) and save them to a similarly named folder on drive
D:, first create a folder on drive C: called BATFILES and then
create a folder called DATA on drive D:
Now open a text editor like Notepad and enter:
xcopy
c:\data\*.* d:\data /s/m/y
This is a DOS batch file, remember, so be prepared
for a little tweaking if the folder name contains more than eight
characters.
If this proves to be the case, you can use the tilde
sign (~) to shorten the name in the batch file and make it only
eight characters long. For example, to create a batch file that will
backup files from C:\Documents and Settings\Dave Cook\My Documents
to a folder on drive E: called My Documents, enter:
xcopy
c:\Docume~1\DaveCo~1\MYDOCU~1\*.* e:\MYDOCU~1 /s/m/y
Watch those spaces! When you’re finished, save the
text file as BACKUP.BAT and store it in the folder C:\BATFILES.
Macro
Now we’re ready to create the macro. Open Word and
choose Tools, Macro, Macros. You probably won’t have
to enable macros, but if you do you can still maintain a high
security level by assigning a list of trusted macro sources, and
electing to trust all installed add-ins and templates. It goes
without saying that you should also be running an up to date
antivirus program.
In the macro name window enter AutoExit, and
click Create. This takes you to Word’s VBA editor. In
the VB editor window, clear any existing lines and enter the
following text:
Sub AutoExit()
Dim Backup, Style, Title,
Response
Backup = "Backup File,
Cookie?"
Style = vbYesNo +
vbDefaultButton1 + vbQuestion
Title = "Optional Backup on
Exit"
Response = MsgBox(Backup,
Style, Title)
If Response = vbYes Then
Dim RetVal
RetVal = Shell("c:\batfiles\backup.bat",
1)
End If
End Sub
On the Backup line, note that the text placed within
the quotes “Backup File, Cookie?” will be the text that
appears when you’re prompted to backup the files. Obviously, this
text should be altered to suit your own requirements. Everything
else should be entered exactly how it appears above. When you’re
finished, close the macro to save it.
Finally
Next time you close Word an Optional Backup On
Exit box will appear. Click the YES button and all the
files contained within your chosen folder on drive C: will be copied
to a folder and drive stipulated in the batch file you created
earlier.
From this point onwards you will be given the
opportunity to backup your files every time you exit Word. And
because these backups are incremental, only new or altered files
will be updated on the second drive.
|