Name Statement |
Name oldpathname As newpathname
oldpathname
Use: Required
Data Type: String
The current filename and optional path.
newpathname
Use: Required
Data Type: String
The new filename and optional path.
Renames a disk file or folder.
newpathname must not already exist or an error is generated.
newpathname and oldpathname can't be on different drives.
Path information included in newpathname and oldpathname can take the form of the local system's path or the UNC path.
newpathname and oldpathname can't include the wildcard characters ? and *.
You can't use the Name statement with a file that is already open.
The Name statement can move a file from one folder to another, and optionally, can change the file's name at the same time. If the folder specified in newnamepath exists and is different from that stated in oldnamepath, the file is moved to the folder specified in newnamepath. If the filename in newnamepath is also different, the file is renamed at the same time. Moving an object in this way, however, only works with files; you can't use the Name statement to move folders.