VBA Access help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Thanks for your reply. Didnt work says "External procedure not valid", is it
because the code is for VB6 and not VBA?
 
It Worked like a charm!!! Thanks Douglas, It just needed some corrections!
 
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?
 
"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.
 
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.
 
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>
 
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!!
 
Good catch... one should always double proofread "air code" before
posting... which I obviously didn't do! < g >
 

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

Back
Top