Be the first user to complete this post

  • 0
Add to List

FileSystemObject : CopyFile Method

Description: 

This function copies one or more files from one location to another.

Format : 

objectOfFileSystemObject. CopyFile (source, destination[, overwrite] );

Arguments: 
  • objectOfFileSystemObject

As the names says, it’s a FileSystemObject.

  • source
    • Mandatory
    • Type:     String
    • File name to be copied.
  • destination
    • Mandatory
    • Type:     String
    • Path where file to be copied.
  • overwrite
    • Optional
    • Type: Boolean ( True(default): if existing files to be overwritten, False: if not overwritten)
       Function FnCopyFile(strSourceFile,strDestinationPath)

           Set fso = CreateObject("Scripting.FileSystemObject")

           fso. CopyFile(strSourceFile, strDestinationPath)

      End Function

Call FnCopyFile(“c:\mydocuments\file.xls”,”c:\NewFolder”)



Also Read:

  1. FileSystemObject : FileExists Method
  2. Excel-VBA : Insert Multiple Images from a Folder to Excel Cells
  3. FileSystemObject : FolderExists Method
  4. VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.
  5. FileSystemObject : GetFolder Method