Using FTP Download in VBA Code

Using FTP Download in VBA Code

Post by Steve Lan » Sat, 31 Jul 2004 01:20:04


Hi all,

I am trying to use the minet.ocx to automatically download a file on a FTP
site. I downloaded the code snippet from the MVPS.org website and set it all
up. I must be doing something wrong, since the file never transfers but I
don't get an error message! I can manually drag and drop the file so I know
I have access to the FTP site.
Below is the code. Any help is appreciated.

^^^^^^^^^^^^^^^^START CODE
Sub FTPCheck()
Const cHost = "www.leg.state.nv.us"
Const cUserName = ""
Const cPW = ""
Dim strData As String
Dim strTempFile As String

strData = "Test Document.doc"
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) As Boolean

Dim FTP As Inet

Set FTP = New Inet
With FTP
.Protocol = icFTP
.RemoteHost = HostName
.UserName = UserName
.Password = Password
.Execute .URL, "Get " & RemoteFileName & " " & LocalFileName
Do While .StillExecuting
DoEvents
Loop
DownloadFile = (.ResponseCode = 0)
End With
Set FTP = Nothing
End Function

^^^^^^^^^^^^^^^^^^^^^^^^ END CODE
TIA and have a great day!

Steve
 
 
 

Using FTP Download in VBA Code

Post by Steve Lan » Sat, 31 Jul 2004 02:47:36

Hi all,

I figured out the problem. The web dudes gave me the wrong FTP address. No
problems, once it is the correct place to go!

Steve



all
know

 
 
 

Using FTP Download in VBA Code

Post by Steve Lan » Sat, 31 Jul 2004 05:14:30

I got it to work on one machine, but on three others I get an error on the
line:

Set FTP = New Inet

The error is "429: ActiveX cannot create object"

I have the references loaded on the user's computer, and I copied and
registered the msinet.ocx as well. Anyone have any ideas as to what to look
for now?

TIA and have a great day!

Steve






FTP
I