View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Donna S Donna S is offline
external usenet poster
 
Posts: 16
Default Moving all files to a different location

I need help changing this macro I received from Vergel Adriano. It works but
I would like it to always move all the files in F:\temp and not ask me were
the source is and I was wondering if it could ask me to browse to the
destination location so I wouldn't have to type it in the Imput box. Is this
possible??? Thanks,

Sub test()
Dim strSource As String
Dim strDest As String
Dim strFileName As String

strSource = InputBox("Enter source folder path")
strDest = InputBox("Enter destination folder path")

strFileName = Dir(strSource, vbDirectory)
If strFileName = "" Then
MsgBox "Source Folder path is invalid", vbCritical
Exit Sub
End If

strFileName = Dir(strDest, vbDirectory)
If strFileName = "" Then
MsgBox "Destination Folder path is invalid", vbCritical
Exit Sub
End If

strFileName = Dir(strSource & "\*.*")
While strFileName < ""
Name strSource & "\" & strFileName As strDest & "\" & strFileName
strFileName = Dir
Wend

End Sub