How to copy files in VBA?

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)

Thanks

Mark
mlagrangeAsked:
Who is Participating?
 
mbizupConnect With a Mentor Commented:
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
0
 
hongjunCommented:
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
0
 
mlagrangeAuthor Commented:
Thanks a million! The FSO is a wonderful thing!

Mark
0
 
mbizupCommented:
Glad to help :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.