This short tutorial will demonstrate how to use CopyFolder method of the FileSystemObject.
Copy Folder with VBA FileSystemObject
This lesson uses the FileSystemObject. In order to use it, you will need to set a reference to the VB script run-time library. See here for more information.
Copying folders is easy with the CopyFolder method of the FileSystemObject.
Sub FSOCopyFolder() Dim FSO As New FileSystemObject Set FSO = CreateObject("Scripting.FileSystemObject") FSO.CopyFolder "C:\Src", "C:\Dst\" 'Dst folder exists FSO.CopyFolder "C:\Src", "C:\DstNew" 'DstNew folder is created End Sub
If source contains wildcard characters, or destination ends with a path separator (\), it is assumed that destination is an existing folder in which to copy matching folders and subfolders. Otherwise, destination is assumed to be the name of a folder to create.
VBA Coding Made EasyStop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!