Written by Allen Wyatt (last updated November 26, 2018)
This tip applies to Word 97, 2000, 2002, and 2003
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.
Note:
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.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Sometimes it is helpful to know how often a particular phrase appears within a document. If you need to know such a ...
Discover MoreNeed to format your document using a macro? You can easily set the right margin for an individual paragraph by using the ...
Discover MoreWhen you are printing a document, it is not unusual to see messages (dialog boxes) periodically. When you want the ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
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>
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments