How to copy files in VBA?

Posted on 2007-07-31
Last Modified: 2012-05-05
Hello - How can I copy the contents of one folder to another folder in VBA (Access 2003) ?
(assume it's ok to overwrite existing files with the same name in the destination folder)


Question by:mlagrange
    LVL 61

    Accepted Solution

    Make sure you have the reference for MS SCripting Runtime checked.

    Then use this VBA:

        Dim fso As New Scripting.FileSystemObject
        fso.CopyFolder "C:\MyFolder", "C:MyNewFolder", True
    LVL 33

    Expert Comment

    Using VBA.

    Before that, you need to add a reference
    Tools -> References
    Check "Microsoft Scripting Runtime".

        Dim fso As New FileSystemObject
        fso.CopyFolder "C:\Folder1", "C:\Folder2", True
        Set fso = Nothing

    Author Comment

    Thanks a million! The FSO is a wonderful thing!

    LVL 61

    Expert Comment

    Glad to help :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now