Name Statement
Renames a disk file, directory, or folder.
Syntax
Name oldpathname As newpathname
The Name statement syntax has these parts:
Part Description
oldpathname Required. String expression that specifies the existing file name and location—may include directory or folder, and drive.
newpathname Required. String expression that specifies the new file name and location—may include directory or folder, and drive. The file name specified by newpathname can't already exist.
Remarks
Both newpathname and oldpathname must be on the same drive. If the path in newpathname exists and is different from the path in oldpathname, the Name statement moves the file to the new directory or folder and renames the file, if necessary. If newpathname and oldpathname have different paths and the same file name, Name moves the file to the new location and leaves the file name unchanged. Using Name, you can move a file from one directory or folder to another, but you can't move a directory or folder.
Using Name on an open file produces an error. You must close an open file before renaming it. Name arguments cannot include multiple-character (*) and single-character (?) wildcards.