Download file to computer from FTP

S

Sabosis

Hello-

I found the following code to download a csv file from an FTP site,
but I am getting an error message in VB that I don't understand. The
code is below:

Sub FTPCheck()
Const cHost = "ftp://XX.XX.XX.XXX/VERPNDDIV.csv"
Const cUserName = "MyUserName"
Const cPW = "MyPassword"
Dim strData As String
Dim strTempFile As String


strData = "VERPNDDIV.csv"
strTempFile = "C:\" & strData

MsgBox DownloadFile(cHost, cUserName, cPW, strData, strTempFile)

End Sub


Function DownloadFile(ByVal HostName As String, _
ByVal UserName As String, _
ByVal Password As String, _
ByVal RemoteFileName As String, _
ByVal LocalFileName As String)

Dim FTP As InetCtlsObjects.Inet <----This is the line that is
highlighting as an error
Set FTP = New InetCtlsObjects.Inet
With FTP
.URL = HostName
.Protocol = 2
.UserName = UserName
.Password = Password
.Execute , "Get " + RemoteFileName + " " + LocalFileName
Do While .StillExecuting
DoEvents
Loop
DownloadFile = (.ResponseCode = 0)
End With
Set FTP = Nothing
End Function

Does anyone have any ideas? Or know of a simple way to pull a csv file
from an FTP site using code? Any help would be appreciated.

Thanks-

Scott
 

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

Top