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

D

Douglas J. Steele

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.
 
F

Frank Dulk

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.
 
D

Douglas J. Steele

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
 
F

Frank Dulk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top