How to move files from the code

A

Ana

Hi ,
does anyone know how to move all the file from one folder
to another from the code ?
For example : move *.* from C:\A to C:\B

thanks
ana
 
D

Don Guillett

try
Sub movefile()
OldName = "C:\Al\yourfilename.xls"
NewName = "C:\B\yourfilename.xls"
Name OldName As NewName
End Sub
 
N

Norman Jones

Hi Ana,

Try this routine posted by Dana deLouis:


Sub FilesMoveBetweenFolders()

Const FromFolder As String = "D:\Assets\*.*"
Const ToFolder As String = "D:\Closing\"

On Error Resume Next
With CreateObject("Scripting.FileSystemObject")
.CopyFile FromFolder, ToFolder, True
.DeleteFile FromFolder, True
End With

End Sub
 
B

Bob Phillips

Hi Ana,

Try this

name "C:\MyDir" as "C:\NewDir"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top