One of the companies I consult for stores its documents on a LAN and requires that printed copies display a path in the document footer. It’s easy to set this up in a Word document via the Header And Footer toolbar. But in Excel 95, 97, and 2000, the header and footer options are much more rudimentary; there isn’t an obvious way to insert the document path.

A common workaround is to type the document’s path into the footer manually. While a sensible solution, this approach is more labor-intensive; typing a single document path is no big deal, but in a company that maintains hundreds or thousands of spreadsheets, the effort can really add up. Also, the typed path is static; if the spreadsheet is moved or saved to a new location, the path doesn’t change. And that fact might not get noticed until the document is printed, wasting both time and paper.

However, you can use a simple, one-line Visual Basic script in Excel 2000 to allow printing of a self-updating file path in the footer of your worksheets. The script even gives you a number of positioning options.

Check your headers and footers

A common laborsaving approach is to reuse existing document files as templates for new work. Unfortunately, since several view modes in both Word and Excel don’t display the header and footer, it’s easy to overlook these elements until the document is printed. Headers and footers that do not use automatically updating fields can contain incorrect filenames, page counts, and other information. Taking a few moments to check the information in a document’s header and footer can prevent waste and confusion.

Basic header and footer technique
Most people are familiar with how Word handles file paths in headers and footers; it’s quite different from Excel. In Word, you click View | Header And Footer to invoke the Header And Footer toolbar. If you’re using Print Layout view, you can also double-click on the footer area. To add a file path to the footer, you simply choose Filename And Path from the Insert AutoText drop-down menu, as shown in Figure A.

Figure A
Word lets you insert a filename and path into your footer via a simple drop-down menu.

Works in Excel 95 and 97, too

I’ve used Excel 2000 in my examples. However, the script I explain below works in Excel 95 and 97 as well.

Excel 2000 handles things a little differently. Clicking View | Header And Footer in Excel invokes the Page Setup dialog box with the Header/Footer tab activated, as shown in Figure B. From this dialog box, you can select common footer entry options from the list (i.e., page number, worksheet name) from the Footer drop-down menu, or you can click the Custom Footer button to create your own entry.

Figure B
Excel lets you choose from preset footer entries or create a custom footer, but its options are limited.

In the Footer dialog box, shown in Figure C, you can type text into the left, right, or center sections, choose an entry from one of the seven buttons in the middle of the dialog box (where the entry goes depends on what section your cursor occupies), or combine one of these entries with text you enter. The seven selections are represented as icons. The options are (from left to right in the image):

  • Font
  • Page number
  • Total number of pages
  • Date
  • Time
  • Filename
  • Worksheet name

Figure C
Excel 2000 doesn’t provide a file path footer option.

As you can see, there is no option for entering a file path. To do this, you can use a simple Visual Basic script.

No need for the script in Excel 2002

Excel 2002 does offer a file path option; you can click the button or type the code &[Path] into one of the sections of the Custom Footer dialog box.

The script
The script is easy to use, even if you don’t have much Visual Basic experience. Simply choose Tools | Macros | Visual Basic Editor or press [Alt][F11]. With the Visual Basic Editor open, choose Insert | Module. In the resulting window, type the following code:
Sub FooterPath()
ActiveSheet.PageSetup.LeftFooter = ActiveWorkbook.FullName
End Sub

Close the Visual Basic Editor and return to the spreadsheet. Be sure to save the workbook before running the macro. Next, click Tools | Macro | Macros, make sure the FooterPath macro is selected, and then click Run.

That’s it! The spreadsheet will then have the full path in the footer. To confirm, click the Print Preview button on the Standard toolbar. You’ll see the path at the bottom, as shown in Figure D. If you’re comfortable with Visual Basic, you can alter the script to place the path in the right-hand corner, center, or header.

Figure D
The macro places the path at the bottom of your worksheet.

If you move or rename the worksheet, you’ll need to run the macro again. But you can save this macro as part of your Normal template, so it’s always available. Also, you can create a macro button or key combination to make updates a cinch.