Need to understand command structure in VBA for Word

Coates, Donald 5 Reputation points
2026-10-15T12:27:16.52+00:00

Is CopyFolder a standard command or is it a combination of Copy and Folder?

Developer technologies | VB

3 answers

Sort by: Most helpful
  1. Brian Pham (WICLOUD CORPORATION) 1,340 Reputation points Microsoft External Staff Moderator
    2026-10-16T04:08:59.5066667+00:00

    Hi @Coates, Donald ,

    Thanks, you for your question

    CopyFolder is a single method name and not a combination of the keywords Copy and Folder. In VBA, it is a method of the FileSystemObject object that is used to copy a folder and its contents (including subfolders).

    For example:

    	Dim fso As Object
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	
    	fso.CopyFolder "C:\SourceFolder", "C:\DestinationFolder"
    
    

    The syntax is: object.CopyFolder source, destination, [ overwrite ]

    where:

    • object is a FileSystemObject
    • source is the folder to copy
    • destination is the target location
    • overwrite is an optional parameter that defaults to True

    If you're trying to understand VBA command structure in general, methods such as CopyFolder, CopyFile, MoveFolder, and MoveFile are predefined method names provided by the FileSystemObject library rather than combinations of separate VBA commands.

    For additional details, you can refer to the Microsoft documentation for the CopyFolder method and FileSystemObject object.

    If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you.

    Was this answer helpful?

    3 people found this answer helpful.

  2. Marcin Policht 113.2K Reputation points MVP Volunteer Moderator
    2026-10-15T12:40:46.3233333+00:00

    In VBA for Word, CopyFolder is a method of the FileSystemObject object, provided by the Microsoft Scripting Runtime library. It is a single, established method name, not a combination of separate Copy and Folder commands. It is not a native VBA language statement, but you can use it in Word VBA through the FileSystemObject object.

    The CopyFolder method copies a folder and its contents, including files and nested subfolders. Its syntax is:

    object.CopyFolder source, destination, [overwrite]
    

    The object is a FileSystemObject instance. The source specifies the folder or folders to copy, and the destination specifies where they should be copied. The optional overwrite argument determines whether existing files are overwritten; its default value is True. Wildcards can be used in the source path to copy multiple matching folders.

    For example, the following Word VBA code copies the Reports folder and its contents to D:\Archive\Reports:

    Sub CopyReportsFolder()
        Dim fso As Object
        Set fso = CreateObject("Scripting.FileSystemObject")
        fso.CopyFolder "C:\Reports", "D:\Archive\Reports"
        Set fso = Nothing
    End Sub
    

    There is also a separate Copy method available on individual File and Folder objects. For example, calling Copy on a Folder object copies that folder and its contents. The distinction is that Folder.Copy operates on a specific folder object, while FileSystemObject.CopyFolder accepts source and destination paths and supports wildcard patterns for copying multiple folders.

    Note that CopyFolder does not create missing parent directories in the destination path. The destination's parent directory must already exist. If a destination folder already exists, the copied source folder's contents may be placed inside it, depending on the source and destination paths.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-10-15T12:27:30.0866667+00:00

    CopyFolder is a standard method name, not a combination of Copy and Folder.

    In VBA, CopyFolder is a method of the FileSystemObject object. Its purpose is to recursively copy a folder from one location to another.

    Its syntax is:

    object.CopyFolder source, destination, [ overwrite ]
    

    Key points:

    • object is a FileSystemObject
    • source is the folder or folders to copy
    • destination is where the folder and subfolders are copied
    • overwrite is optional and defaults to True

    There is also a separate Copy method for a File or Folder object. The documentation states that using Copy on a Folder gives the same result as using FileSystemObject.CopyFolder for that folder, but CopyFolder can copy multiple folders.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.