VBA CopyFile

The FileSystemObject VBA CopyFile method copies one or more files from one a source to a destination location.

VBA CopyFile Syntax

fso.CopyFile source, destination, [ overwrite ]

source
The source location of the file or files. You can use wildcards such as *.* to specify more than a single file matching the pattern.
destination
The destination location (folder) where the source files are to be copied to.
overwrite
Optional. If True will overwrite files with same name in destination folder. If True it will omit files for which there is an existing filename in the destination folder.

VBA CopyFile Examples

Set fso = CreateObject("Scripting.FileSystemObject")

'Copy just the Hello.xlsx file
fso.CopyFile "c:\Src\Hello.xlsx", "c:\Dest\" 

'Copy all files with XLSX extension to destination folder
fso.CopyFile "c:\Src\*.xlsx", "c:\Dest\" 

'Copy all files to destination folder
fso.CopyFile "c:\Src\*.*", "c:\Dest\" 

'Copy all files in subfolders of C:\Src to destination folder
fso.CopyFile "C:\Src\*\*.*", "c:\Dest\"