Runtime Error 74: “Can't rename with different drive,” explained and fixed
Error 74, “Can't rename with different drive”, fires when the Name statement is asked to move a file to a different drive or volume. Name only relabels a file within its own directory structure; it cannot carry data across devices. Code that builds a destination on another drive (a local temp file “renamed” onto a network share is the classic) hits error 74 every time. It is a code bug about choosing the wrong operation, not a problem with either drive.
For people who just run the program
- Expect it in archive and export steps. Tools that finish a job by “moving” output from a working folder to a server folder are where cross-drive renames hide.
- Check whether the working folder changed location. If the tool or its temp folder moved to another drive recently, a rename that used to be within one drive may now silently cross two.
- Do not move the destination to match. The fix belongs in the program's move logic; rearranging shared folders to appease it disrupts everyone else.
- Report the source and destination folders if the tool shows them. Two paths on different drive letters are the whole diagnosis.
For people who write the code
- Use copy plus delete to cross volumes.
FileCopy the file to the destination, verify it arrived, then Kill the source. That is what a cross-drive move physically is:
FileCopy srcPath, dstPath ' works across drives
Kill srcPath ' remove the original after success
' Name srcPath As dstPath ' error 74 when drives differ
- Verify before deleting. Compare file sizes (or hashes for critical files) after the copy. Deleting the source on an unverified copy converts a network hiccup into data loss.
- Compare volumes, not letters. Two different letters can be the same volume, and one letter can be a mapped path to anywhere. When the code chooses its strategy, compare the drive portion of both paths; if they differ, take the copy path.
Error 74 is a gift: the operation failed before doing anything. Unlike a half-finished manual move, a failed Name changes nothing on either drive. Code that “recovers” by deleting the destination and retrying the same rename misunderstands the error completely.
If it still happens
If both paths show the same drive letter and error 74 still fires, one of the paths is a mapped or substituted drive and the other is its UNC target, or a junction is involved: the strings match while the volumes differ. Resolve both to their real locations and compare those.
Common questions
Why can File Explorer move files across drives but Name cannot? Explorer performs a copy followed by a delete when the destination is on another volume. VBA's Name statement only performs the rename operation itself, which is defined within a single volume.
Does error 74 damage either file? No. The rename is rejected before anything changes. The source stays where it was and no destination file is created.
Related errors