Folder Copy (1 Viewer)

StuBailey

Registered User.
Local time
Today, 14:20
Joined
Sep 20, 2001
Messages
15
I can't seem to get my head round the CopyFolder using the FileSystemObject. Has anybody got an example or know of another way I can copy a folder and all files/subfolders underneath from one location to another using Access VBA?

Cheers

Stu:confused:
 

StuBailey

Registered User.
Local time
Today, 14:20
Joined
Sep 20, 2001
Messages
15
Hi,

Thanks for the help, your 'Moving files in code' link is the most handy.

I couldn't seem to get it to work though. I need to copy a folder and everything under it files and folders to a new location.

Cheers

Stu
 

BukHix

Registered User.
Local time
Today, 10:20
Joined
Feb 21, 2002
Messages
379
With the files and folders have static names or will they change often?
 

StuBailey

Registered User.
Local time
Today, 14:20
Joined
Sep 20, 2001
Messages
15
All top level folder names are picked up from the database I am working in, those folders under that main folder may change, but could be picked up from a database under that first folder, all the file names will be the same as what are in the other folders of the same level, it starts getting a bit complex with linking then etc. if I am going to use the databases.

I hoped I could use just one line of code, but that no longer looks likely.
 

Jon K

Registered User.
Local time
Today, 14:20
Joined
May 22, 2002
Messages
2,209
The following code will copy all files and subfolders from C:\SourceFolder to C:\DestinationFolder. Existing files in destination bearing the same names as in the source will be overwritten.

If C:\DestinationFolder does not already exist, the destination folder will be created.

-----------------------------------
Dim oFileSys As Object

Set oFileSys = CreateObject("Scripting.FileSystemObject")

oFileSys.copyfolder "C:\SourceFolder", "C:\DestinationFolder"
------------------------------------
 

BukHix

Registered User.
Local time
Today, 10:20
Joined
Feb 21, 2002
Messages
379
Thanks Jon K that is a lot more elegant then the code I was cobbling together. :D
 

StuBailey

Registered User.
Local time
Today, 14:20
Joined
Sep 20, 2001
Messages
15
Going back to my first post about the FileSytemObject, I can't believe I forgot to dim my object!?!?! Other than that, it would have worked!

Cheers guys!
 

Users who are viewing this thread

Top Bottom