Jonmo1
MrExcel MVP
- Joined
- Oct 12, 2006
- Messages
- 44,061
Hatman directed me to this post for help downloading from an FTP Site.
http://www.mrexcel.com/forum/showthread.php?t=261043&highlight=ftp
It gave me this code.
But it errors on the line
Set FTP = New Inet 'InetCtlsObjects.Inet
The error is
Runtime error 429
ActiveX component can't create object
I've set the reference to Microsoft Internet Transfer Control
And Ive run "regsvr32 msinet.ocx" - it says successfull.
Any help is appreciated.
http://www.mrexcel.com/forum/showthread.php?t=261043&highlight=ftp
It gave me this code.
But it errors on the line
Set FTP = New Inet 'InetCtlsObjects.Inet
The error is
Runtime error 429
ActiveX component can't create object
I've set the reference to Microsoft Internet Transfer Control
And Ive run "regsvr32 msinet.ocx" - it says successfull.
Any help is appreciated.
Code:
Function fnDownloadFile(ByVal strHostName, _
ByVal strUserName As String, _
ByVal strPassWord As String, _
ByVal strRemoteFileName As String, _
ByVal strLocalFileName As String) As String
'// Set a reference to: Microsoft Internet Transfer Control
'// This is the Msinet.ocx
Dim FTP As Inet 'As InetCtlsObjects.Inet
Set FTP = New Inet 'InetCtlsObjects.Inet
On Error GoTo Errh
With FTP
.URL = strHostName
.Protocol = 2
.UserName = strUserName
.Password = strPassWord
.Execute , "Get " + strRemoteFileName + " " + strLocalFileName
Do While .StillExecuting
DoEvents
Loop
fnDownloadFile = .ResponseInfo
End With
Xit:
Set FTP = Nothing
Exit Function
Errh:
fnDownloadFile = "Error:-" & Err.Description
Resume Xit
End Function