Copying files

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

Guest

Hi there, i have a button on my form which when clicked creats 5 new folders
in a new directory. I was wondering how i would go about copying two files
from a diorectory and putting them in the newly created folder as well each
time the button is pressed, thanks! WK
 
bilbo+ said:
Hi there, i have a button on my form which when clicked creats 5 new folders
in a new directory. I was wondering how i would go about copying two files
from a diorectory and putting them in the newly created folder as well each
time the button is pressed, thanks! WK

Access has the built in VBA command FileCopy.

FileCopy "SourcePath", "DestinationPath"
 
Hi again, i dont know what im doing wrong...
but this is what im using but it doesnt seem to work, it creates the folders
but doesnt copy the files accross. I want it to go into the relevant jobno
directory that has jsut been created.. thanks

Private Sub Command169_Click()
Dim strPath As String

strPath = "\\Server\CKS Database\CKS\Data\" & Me.JobNo
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir (strPath)
MkDir (strPath & "\Services")
MkDir (strPath & "\Drawings")
MkDir (strPath & "\Invoices")
MkDir (strPath & "\Sales")
MkDir (strPath & "\Suppliers")
MkDir (strPath & "\Emails")
MkDir (strPath & "\Emails\PKL")
MkDir (strPath & "\Emails\Client")
MkDir (strPath & "\Emails\Misc")
FileCopy "\\Server\CKS Database\CKS\Hire Quote.doc", "strPath"
FileCopy "\\Server\CKS Database\CKS\Hire Calc.XLS", "strPath"

End If
Shell "explorer.exe " & strPath, vbNormalFocus
 
bilbo+ said:
Hi again, i dont know what im doing wrong...
but this is what im using but it doesnt seem to work, it creates the folders
but doesnt copy the files accross. I want it to go into the relevant jobno
directory that has jsut been created.. thanks

Private Sub Command169_Click()
Dim strPath As String

strPath = "\\Server\CKS Database\CKS\Data\" & Me.JobNo
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir (strPath)
MkDir (strPath & "\Services")
MkDir (strPath & "\Drawings")
MkDir (strPath & "\Invoices")
MkDir (strPath & "\Sales")
MkDir (strPath & "\Suppliers")
MkDir (strPath & "\Emails")
MkDir (strPath & "\Emails\PKL")
MkDir (strPath & "\Emails\Client")
MkDir (strPath & "\Emails\Misc")
FileCopy "\\Server\CKS Database\CKS\Hire Quote.doc", "strPath"
FileCopy "\\Server\CKS Database\CKS\Hire Calc.XLS", "strPath"

End If
Shell "explorer.exe " & strPath, vbNormalFocus

Since your paths have spaces in them you might need to double up the quotes. I
usually do that with Chr(34)...

FileCopy Chr(34) & "\\Server\CKS Database\CKS\Hire Quote.doc" & Chr(34),
"strPath"

If that is not the issue then check to see if the file you are copying is
currently open. You cannot use FileCopy on an open file.
 

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