Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

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”)

 

You may also like...

2 Responses

  1. Eric Martin says:

    This keeps returning a Compile Error expect = on the fso. copyfile line

    • sumitjain says:

      Everything looks fine for me…can u send me your code?… Just to mention wen u copy paste the code double-course ‘ ” ‘ doesn’t get copy well every time…we need remove and put it again.

      Thanks
      Sumit

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: