How do I copy a folder from a server using a macro

M

macrowriter

I need to copy files and folders from a server to my hard drive using a
macro. I'm not sure how to write the macro using visual basic.
 
J

Jim Thomlinson

Same as in DOS except using the FileCopy command

FileCopy "source", "destination"
 
M

macrowriter

FILECOPY C:\DOCUMENTS\QUIZ april.doc , C:\ARCHIVED\DOCUMENTS\TEST april.doc
here is what I'm trying to do.... am i missing anything?
 
J

Jim Thomlinson

Since the files names have spaces in them throw quotes aroung them...

FILECOPY "C:\DOCUMENTS\QUIZ april.doc" , "C:\ARCHIVED\DOCUMENTS\TEST
april.doc"
 
K

KtM

You are missing "", ie
filecopy "what","to"
for example.
filecopy "c:\test.xls","c:\test2.xls"
or use same method as VBA example and use variables, which makes it
easier to change if used repeatedly.
 
M

macrowriter

This was very helpful... here is what I have sofar... however I can only seem
to move one file at a time. how can I change this to move all files in the
folder?

Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "My Document" file from "Macintosh HD:Documents"
' to "Macintosh HD:Backup".
FileCopy sSourcePath, sTargetPath

If Err > 0 Then MsgBox Err.Description
End Sub
 

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