How to move files from the code

  • Thread starter Thread starter Ana
  • Start date Start date
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
 
try
Sub movefile()
OldName = "C:\Al\yourfilename.xls"
NewName = "C:\B\yourfilename.xls"
Name OldName As NewName
End Sub
 
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
 
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)
 

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