- Display the filename in a custom header.
- Display the filename in a cell using the Cell() function.
Let's tackle the easiest solution first. To display the workbook's name in a cell, enter the function =Cell("filename"). This function will display the workbook's full name. If the workbook hasn't been saved, the function displays an empty string ("").
Displaying the file's name in a header or footer is a bit more traditional. To do so, complete the following steps:
- Choose Header and Footer from the View menu.
- Click Custom Header or Custom Footer.
- The resulting dialog box will offer three positions — Left, Center, and Right. Click inside the appropriate section.
- Click the File Path or the FileName icon.
- Click OK twice.
Excel won't display the header in normal view. To see the header, you must click Print Preview or print content.
There are a few more differences between these two name-displaying methods:
- Cell() includes brackets, which you probably won't want if your only purpose is to just display the name.
- Cell() always displays the full pathname, including the current sheet. The custom header/footer option never displays the sheet name.
- Cell() displays the name in a sheet, which you can see while working in the file. You'll see the header/footer only in Print Preview or on the printed page.
- Cell() displays the workbook's name only once, in the cell where you inserted it. The header/footer option displays the name on each printed page.
- Cell() doesn't automatically update if you save the workbook's name. You must press [F9]. The header/footer updates automatically.
Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.