copy several files of a folder for other, using VBA?

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
You have to copy them one-by-one. If you're wanting to copy all files
matching a particular pattern, use the Dir function to determine the files.
 
They are files *.XLS

Douglas J. Steele said:
You have to copy them one-by-one. If you're wanting to copy all files
matching a particular pattern, use the Dir function to determine the files.
 
Dim strDestinationFolder As String
Dim strSourceFolder As String
Dim strFile As String

strDestinationFolder = "C:\Another Folder\"
strSourceFolder = "C:\My Data\"

strFile = Dir$(strSourceFolder & "*.XLS")
Do While Len(strFile) > 0
FileCopy strSourceFolder & strFile, strDestinationFolder & strFile
strFile = Dir$()
Loop
 
Thank you very much.


Douglas J. Steele said:
Dim strDestinationFolder As String
Dim strSourceFolder As String
Dim strFile As String

strDestinationFolder = "C:\Another Folder\"
strSourceFolder = "C:\My Data\"

strFile = Dir$(strSourceFolder & "*.XLS")
Do While Len(strFile) > 0
FileCopy strSourceFolder & strFile, strDestinationFolder & strFile
strFile = Dir$()
Loop
 
Back
Top