Our Blog

Calling for Backup (Part 1)

by | Dec 3, 2019 | , | Tools of the Trade | 0 comments

UPDATE: I have adjusted the batch file slightly so that it provides the name of the file being backed up in error messages, in case users want to use it to back up something other than the normal template.

Word’s Normal.dotm template is the repository for the default styles that determine the appearance of your Word documents. It is also the default location for storing your macros and keyboard shortcuts. Occasionally this file becomes corrupted, and then Word happily replaces the damaged file with a fresh new copy so that it can continue to chug along. But this means that any customizations you have made will be lost.

It isn’t clear why Word does not provide an option to automatically backup and restore this file, as it would save a lot of trouble. Of course, in a perfect world, everyone backs up their computer regularly, so this isn’t a problem. But in case you are one of the 20% of people who don’t—or if you want to make a copy for moving to another computer or for some other reason—manually making a backup copy is a fairly simple process:

  1. Verify that Word is closed (to make sure any template changes are saved).
  2. Navigate to the template folder (C:\Users\[user name]\AppData\Roaming\Microsoft\Templates\) and find Normal.dotm, the Normal template. This is in a hidden folder, so you can either paste the path above into File Explorer and substitute the appropriate user name or you can reveal hidden items by clicking on the File Explorer’s View button and toggling “Hidden items” in the Show/hide portion of the ribbon.
  3. Make a copy of the Normal template, giving it an appropriate name, such as Normal-backup.dotm. It is a good idea to put this backup file (or a copy of it) in another location as insurance against something catastrophic like a hard disk crash.

When your Normal template is eventually corrupted and replaced by Word, substituting your backed-up version is similarly simple:

  1. Verify that Word is closed (as the Normal template cannot be renamed or deleted while it is in use).
  2. Navigate to the template folder.
  3. Rename the new Normal.dotm template Word generated. Or delete it, as Word will create a new copy if one is not found.
  4. Make a copy of your backup file and rename it Normal.dotm.
  5. Open Word and verify that everything is working the same as before the corruption.

It is advisable to back up the Normal template whenever you add a macro, change a keyboard shortcut, or adjust a built-in style (at least if you are concerned about losing these changes). This can become a bit tiresome if done often, and it is easy to get behind if you aren’t having it handled for you automatically.

Batch Files

To simplify the backup process, I’ve created a batch file that completes the steps for making a backup copy. (The batch file is designed to work with Office 365 running in Windows 10, but is adaptable to other versions of Office and Windows if it doesn’t work out of the box.)

A batch file is a program similar to a Word macro, but it runs in Windows and handles operating system functions like copying and deleting files. The batch file in question checks to see that the Normal.dotm template for the logged-in user is where it should be, verifies that the location the backup file will go exists, and makes a renamed copy of the template,  overwriting any older backup that has the same name. While it is only completing a few basic actions, running it is a lot handier than doing the steps manually.

To create the batch file, copy the code provided below, paste it into Word’s Notepad program, and save it as BackupNormalTemplate.bat (or another file name ending with “.bat”).

Asking for Permission

Antivirus software is suspicious of programs that make file changes and will try to get in the way of this batch file. It is possible that you will get an error message—for example, a message that the Normal template cannot be found, even when it is obviously where it should be—if you try to run the batch file at this point (figure 1). The possible remedies vary depending on how your computer is set up and where the batch file is located, but I have found that adding an exclusion for the batch file solves this problem when it occurs.

Figure 1. The error message provided when the Normal template is not found or accessible.

Running the Batch File

To run the batch file, simply double-click on its icon. You will either get a message that it was successful or that it ran into some problem. If you want to verify that it worked, navigate to the template folder and check to see that a backup file is there and has the same date and time as the Normal template.

By default I’ve set the batch file up to save the backup in Word’s template directory, to simplify doing a restoration. But by changing the value of “targetpath” in the batch file you can have it save it to another folder or drive (be sure the new path ends with a backslash: \ ). If your path contains spaces, the targetpath variable must be in quotation marks. You can also change the name of the backup by adjusting the “targetfile” variable.

In Part 2 of this post, I’ll provide instructions on having Window’s Task Manager program periodically run the batch file for you.

The Code

@Echo Off
 set sourcepath=C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Templates\
 set sourcefile=Normal.dotm
 set targetpath=C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Templates\
 set targetfile=Normal_backup.dotm
 if EXIST %sourcepath% (
     cd %sourcepath%
     if EXIST %sourcefile% (
         if EXIST %targetpath% (
             copy /Y %sourcepath%%sourcefile% %targetpath%%targetfile%
             if errorlevel 1 (
                     echo Copying %sourcefile% failed due to an error.
                     echo Try re-running the batch file later.
             ) else (
                 echo Backup of %sourcefile% was successful!
         ) else (
             echo The target destination for backing up %sourcefile% was not found.
             echo Please verify the path is correct and then rerun the batch file.
     ) else (
         echo %sourcefile% was not found and has not been backed up.
         echo Please verify the files exists and you have permission to copy it,
         echo and then rerun the batch file.
 ) else ( 
     echo The folder containing %sourcefile% was not found,
     echo so that file cannot be backed up.
     echo Please verify the path is correct and then rerun the batch file.


Submit a Comment

Your email address will not be published. Required fields are marked *


Sign up to get new blog posts sent directly to your email address and to receive occasional updates about our business and new website content.

Share This