Name
Folder.Copy Method
Syntax
oFolderObj.Copy Destination[,OverwriteFiles]
-
oFolderObj Use: Required
Data Subtype: Folder object
Any object variable returning a Folder object.
-
Destination Use: Required
Data Subtype: String
The path and, optionally, the filename of the copy to be made.
-
OverwriteFiles Use: Optional
Data Subtype: Boolean
Indicates whether existing files and folders should be overwritten (
True) or not (False).
Description
Copies the current folder and its contents, including other folders, to another location.
Rules at a Glance
Wildcard characters can’t be used in
Destination.The folder and all subfolders and files contained in the source folder are copied to
Destination. That is, the Copy method is recursive.Unlike the FileSystemObject.CopyFolder method, there is no operational difference between ending
Destinationwith a path separator or not.
Programming Tips & Gotchas
If the destination path or any of the files contained in the
Destinationstructure are set to read-only, the Copy method will fail regardless of the value ofOverwriteFilesand will generate a “Permission denied” error.If
OverwriteFilesis set toFalse, and the source folder or any of the files contained in theDestinationstructure exists in theDestinationstructure, then trappable error 58, “File Already Exists,” is generated.If an error occurs while copying more than one file, the Copy method exits immediately, leaving the rest of the files uncopied. There is also no rollback facility to undo the copies ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access