0

I am trying to write an Excel VBA macro that will loop through a list of folder paths, fetch all the files inside these folders and copy them to a single folder. Everything works fine until the macro reaches to a file that already exists in the destination folder, and then it returns the message: "run time error 70 - permission denied"

here's the code I'm currently using:

FSO.CopyFolder Source:=FromPath, Destination:=topath

If possible, I would prefer to overwrite the duplicate files.

Thanks in advance!

Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45
Lev
  • 113
  • 1
  • 4
  • 13

1 Answers1

2

The CopyFolder method has an optional OverWriteFiles argument...

FSO.CopyFolder Source:=FromPath, Destination:=topath, OverWriteFiles:=True
Porcupine911
  • 928
  • 9
  • 22