Sub Download_file()
'This macro copy a file from From Source Path to To Destination Path.
Dim FSO As Object
Dim FromFolder As String
Dim ToFolder As String
Dim FileTyp As String
FromFolder = "C:\My Folder" ' The source can be a folder on a server. In this case use \\server\folder\
ToFolder = "C:\Backup" ' The destination folder cab ne on user's hard disc
FileTyp = "*.mp4" 'can use *.* for all files or *.doc for word files
If Right(FromFolder, 1) <> "\" Then
FromFolder = FromFolder & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
' If sorce folder is not found, gives message & exits the program
If FSO.FolderExists(FromFolder) = False Then
MsgBox FromFolder & " doesn't exist. Exiting..."
Exit Sub
End If
' Checks if destination folder exists. If not, it will be created
If FSO.FolderExists(ToFolder) = False Then
MsgBox ToFolder & " doesn't exist, it will create now"
MkDir ToFolder
End If
' File downloading process
FSO.CopyFile Source:=FromFolder & FileTyp, Destination:=ToFolder
MsgBox "File " & FileTyp & " downloaded in " & ToFolder
End Sub
Bookmarks