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: Renaming a File.

Renaming a File

by Allen Wyatt
(last updated March 29, 2014)

1

Your macros can rename a file by using the Name command. This is a holdover from other versions of BASIC. The syntax is:

Name OldFile As NewFile

where OldFile is the name of the old file, and NewFile is the name of the new file. Both filenames must either be string variables or be enclosed in quotes. Both filenames can contain complete path names, but both must be on the same disk drive. If the path names differ, then the command also has the side benefit of apparently moving the file from one directory to another.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (3439) 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: Renaming a File.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using a Formula in a Footer

Excel won't let you place a formula directly into a footer. You can, however, create a simple macro that will produce the ...

Discover More

Adjusting Column Width from the Keyboard

It's easy to adjust the width of table columns using the mouse, but what if you don't want to use the mouse? Adjusting column ...

Discover More

Anchoring Objects by Default

When you position objects (such as text boxes or graphics) on a page, one of the things you can do is to anchor the object so ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

MORE WORDTIPS (MENU)

How to Paste Non-Floating Pictures with a Macro

Using a macro to paste pictures inline instead of floating in Word 97.

Discover More

Detecting an Open Dialog Box

Macros can be used to perform all sorts of tasks within Word. Some tasks can even occur at whatever time interval you desire. ...

Discover More

Determining the Length of a String

Need to find out in a macro how long a particular text string is? You can figure it out by using the Len function, described ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 9?

2014-04-01 12:58:16

Don

Very helpful. I had been doing this with two commands, FileCopy and Kill.

As a word of warning, the Name command (like FileCopy & Kill) will result in Run-time error '75' if the file is currently open.

If the need is to rename an open document (meaning the file with the old name or in the old directory no longer exists), then I suggest using the following
<file>.SaveAs FileName:=<newdir
ewfilename>
Kill <olddiroldfilename>


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing