VBA Access help

A

azirion

What code can I use to program a button in order to copy multiple files from
one place to another. I tried FileCopy but that copies only one file.
Thanks for any help.
 
A

azirion

Thanks for your reply. Didnt work says "External procedure not valid", is it
because the code is for VB6 and not VBA?
 
K

Ken Snell [MVP]

Tell me more about the "location" of your files...are they all in one
folder? do they all have the same file extension? are they all going to the
same folder?
 
L

Larry Linson

"azirion" wrote in message
Thanks for your reply. Didnt work
says "External procedure not valid", is it
because the code is for VB6 and not VBA?

Randy Birch is a Visual Basic MVP. His code would be VB code. I don't know
if the code he has posted is VB6 code, or a different version of VB.
 
A

azirion

Douglas gave me a good example (which I had to fix a little so it could work
on VBA) even though I can use it, if theres a more simple way to do it, I
would apreciate if you can tell me.
The files are pictures all jpg, all in same folder and will be copied to
another folder all together, I must have an option for later on to change the
source folder to another and the destiny folder also.
Thanks for your help Ken.
 
K

Ken Snell [MVP]

Some generic code:

Dim strFileName As String
Dim strPathStart As String, strPathCopy As String
strPathStart = "C:\TheFolderWhereFilesAre\"
strPathCopy = "C:\TheFolderWhereTheCopiesGo\"
strFileName = Dir(strPath & "*.jpg")
Do While strFileName <> ""
FileCopy strPathStart & strFileName, strPathCopy & strFileName
strFileName = Dir()
Loop

--

Ken Snell
<MS ACCESS MVP>
 
A

azirion

Very impresive Ken! Its alot simpler.
Theres only one mistake in one line I had to correct:
strFileName = Dir(strPath & "*.jpg")
It should read:
strFileName = Dir(strPathStart & "*.jpg")

Thank you very much!!
 
K

Ken Snell [MVP]

Good catch... one should always double proofread "air code" before
posting... which I obviously didn't do! < g >
 
Top