How to Copy File or Workbook in Excel VBA?

In this post, you’ll learn how to copy file or Workbook in simple steps using Excel VBA.

Copy File or Workbook in Excel VBA

To copy a file or workbook you can use the FileSystemObject(FSO)command. With this you can access the file system of your computer.

Copy A File or a Workbook

To copy a file or a workbook,

Code:

Dim FSO As Object

 Set FSO = CreateObject("Scripting.FileSystemObject")

 Call FSO.CopyFile("C:\Excel VBA \ Excel VBA 1.xlsx", "C:\ Excel VBA \", True)

Copy and Rename a File

To copy and rename a file,

Code:

Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")

Call FSO.CopyFile("C:\Excel VBA\Excel VBA 1.xlsx", "C:\Excel VBA\Sample file.xlsx")
How to Copy File or Workbook in Excel VBA?