Backup copy

  • Thread starter Thread starter daniel chen
  • Start date Start date
D

daniel chen

I want to make a backup copy of file from C:\Dir_try to F:\Dir_try.
The following code is not working. Please help me to correct it.

Shell Environ("comspec") & " /c copy " _
& Chr(34) & "C:\Dir_try\fundacf.xls F:\Dir_try\fundacf.xl"
 
If you just want to copy a file you can use VBA FileCopy.
FileCopy source, destination
where both arguments are path strings/filenames
 
Thank you, Brian
I tried. It worked fine for a single file for each line.
In fact, I was looking for a batch execution using (*) - a wild card.
Currently, I am using a batch program in a separate operation.
copy "C:\Dir_try\fund*.xls" "F:\Dir_try\fund*.xls"
How might I do to incorporate it into Excel?
 
One can use wildcard characters with "FileSystemObject".

Sub CopyFiles(sFrom As String, sTo As String)
On Error Resume Next
With CreateObject("Scripting.FileSystemObject")
'True for overwrite
.CopyFile sFrom, sTo, True
End With
End Sub

Sub TestIt()
CopyFiles "C:\Dir_try\fund*.xls", "F:\BackupFolder"
End Sub


HTH. :>)

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


daniel chen said:
Thank you, Brian
I tried. It worked fine for a single file for each line.
In fact, I was looking for a batch execution using (*) - a wild card.
Currently, I am using a batch program in a separate operation.
copy "C:\Dir_try\fund*.xls" "F:\Dir_try\fund*.xls"
How might I do to incorporate it into Excel?
 

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