Loading
Word.Tips.Net WordTips (Menu Interface)

Inserting a File Name without an Extension

Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Inserting a File Name without an Extension.

You can use the FILENAME field to insert the current document's file name in your document. The exact way you use this field is described in other issues of WordTips. You can use field switches to specify whether you want the field results to include the full path for the file, or not. One thing you cannot specify, however, is whether you want the results to exclude the file extension.

One way you can control this is by configuring Windows to either display or hide filename extensions. You do that within Windows itself by displaying a folder on your hard drive and then choosing Tools | Folder Options and displaying the View tab.

Scroll through the list of viewing settings, and make sure that the Hide Extensions for Known File Types is set the way you want it. If the check box is clear, then Windows (and Word) always displays the file extension. If it is checked, then the file extension is not displayed.

This approach works great as long as the documents are being viewed on your system. If the document is opened on someone else's system, then the FILENAME field will display the file extension according to the configuration of Windows that they have set up; this may be a drawback.

An easy way to insert the file name without the extension is to use a different field. For instance, you could use File | Properties to set the Title field to the document name (type it in manually) without the extension. You could then use the DOCPROPERTY field to recall that title and insert it in your document.

If you need to insert the document name quite often, the best way to do it is with a macro. Consider the following single-line macro:

Sub InsertFileName()
    Selection.InsertBefore Text:=Left(ActiveDocument.Name, _
      Len(ActiveDocument.Name) - 4)
End Sub

Run this macro, and the name of your document (without the file extension) is inserted before whatever is selected in your document. The macro examines the document name, and then strips the last four characters (the period and file extension) from the name. This is what is inserted.

Using this approach is very easy, but it isn't dynamic. This means that if the document name is changed, then the text in the document still reflects the old document name, not the new one. The way around that is to simply run the macro again to insert the new document name at whatever point you want it to appear.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (292) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Inserting a File Name without an Extension.

Related Tips:

Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective. Check out WordTips: Terrific Tables today!

 

Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form below!)

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 3+4? (To prevent automated submissions and spam.)
 
          Commenting Terms
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2014 Sharon Parq Associates, Inc.