Download Files from FTP server Via Excel Macro

SandeepKumar

New Member
Joined
Dec 15, 2014
Messages
12
Hi All,

I want to download multiple files from FTP server.
I have the log in Credentials of FTP server . Below is the VBA I am using to download files .

VBA Code :


Sub Get_File_From_FTP()
'Variable Declarion Section
Dim FTP As Inet

'Assign Host URL, Source and Destination File path
HostURL = ThisWorkbook.Sheets(1).Cells(1, 1)
FileSource = ThisWorkbook.Sheets(1).Cells(1, 2)
FileDestination = ThisWorkbook.Sheets(1).Cells(2, 2)

'Create New instance of Object and Assign the Parameters
Set FTP = New Inet
With FTP
.URL = HostURL
.Protocol = icFTP
'Replace with your Login and Password Below. Many FTP servers allow Anonymous access with below credentials
.UserName = "My user Name"
.Password = "My Password"
.AccessType = icUseDefault
'Use "Get" to Download and "Put" Option to Upload File to FTP Server
.Execute .URL, "Get " & FileSource & " " & FileDestination
End With
Do While FTP.StillExecuting
DoEvents
Loop

'Status of FTP through Voice Message
Application.Speech.Speak "Process Completed;" & FTP.ResponseInfo

If FTP.ResponseCode = 0 Then
'SomeTime FTP steps will execute successfully, but file will not be there in Destination path
'Search for the file in the Path mentioned in this Message Box
MsgBox "File is Copied to :" & VBA.CurDir
End If
Set FTP = Nothing
End Sub

MSINET.OCX files are also imported in Project .

Please help , while executing the program Compilation error comes" Can't find Project Lib"
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi Sandeepkumar
I have a similar situation. I need to download multiple files from a folder on ftp server to a folder on my pc.
Please post code if you found the solution.

Regards
D Ace
 
Upvote 0

Forum statistics

Threads
1,215,616
Messages
6,125,865
Members
449,266
Latest member
davinroach

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top