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


This func­tion copies one or more files from one loca­tion to another.

Format : 

objectOf­FileSys­te­mOb­ject. Copy­File (source, des­ti­na­tion[, overwrite] );

  • objectOf­FileSys­te­mOb­ject

As the names says, it’s a FileSystemObject.

    • source
      • Manda­tory
      • Type:     String
      • File name to be copied.

  • des­ti­na­tion
    • Manda­tory
    • Type:     String
    • Path where file to be copied.
  • over­write
    • Optional
    • Type: Boolean ( True(default): if exist­ing files to be over­writ­ten, 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 return­ing a Com­pile Error expect = on the fso. copy­file line

    • sumitjain says:

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


Leave a Reply

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

%d bloggers like this: