Excel FTP using msinet.ocx - PROBLEM  
Author Message
terryoleary918





PostPosted: Visual Basic for Applications (VBA), Excel FTP using msinet.ocx - PROBLEM Top

hey

This problem seems to occur a bit but i've not found a solution yet, i hope this is the place to find one.

I'm not a VBA man but my director is and he has a spreadsheet that he wants to automatically upload as part of his report generation (some VBA program he has written).

I've been trying out various ftp solutions , below seems the neatiest BUT when i run the code i get the immortal line : 'Run-time error '429': ActiveX component cant' create object'

This error occurs on the line when i create a new Inet. I have installed a copy of msinet.ocx as my pc didnt have it installed, i registered it and it registered fine (i de registered and reregistered three times now to make sure). I'm developing the code in Visual Basic editor part of Excel 2000 with visual basic version 6.3.

Can anyone suggest whats wrong with this i'm running outta ideas


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

Dim FTP As Inet

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


Private Sub CommandButton1_Click()

Call UploadFile("demonweb.co.uk", "enter", "123456", "c:\report.xls", "/docroot/testing/report.xls")

End Sub

HELP!


i'm guessing this is due to some licensing issue even though i registered it correctly, does any one know how to get round this OR a better way of doing ftp in VBA 6.3



Microsoft ISV Community Center Forums3  
 
 
Ray Fernandez





PostPosted: Visual Basic for Applications (VBA), Excel FTP using msinet.ocx - PROBLEM Top

Hi,

The Inet component cannot be created as an in-memory object. It is an OCX that must be embedded in a form. Create a fake form, put the Inet compopnent there (probably after adding it to the component set), then use it.

If the form name is "Userform1", and the component name is "Inet1", then delete "dim ftp as inet" and change the set to "set ftp= userform1.inet1", voila.

Regards

Ray