Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Upload using MSINET.OCX: Not working

Status
Not open for further replies.

sard0nicpan

Programmer
Dec 28, 2004
57
US
I am trying to upload files to an offsite server. I was directed to a piece of code (by VBSlammer) which should have solved the problem, but did not.

I made the reference to MSINET.OCX (in Access 2000), and everything compiles (NO REPORTED ERRORS) just fine ( I call the function from a form). However, when I call the function (illustrated below: ), it goes as far as
"Set FTP = New Inet" and then returns to my main module, bypassing the rest of the function. Is there something I have forgotten to do?

My call function is the following:

Call UploadFile(HostName, UserName, Password, LocalFileName, RemoteFileName)

Code:
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 'AT THIS POINT, EXECUTION RETURNS TO MODULE
    
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

 
Hi sard0nicpan,
(and everyone else with the same problems)

I did also try a lot of stuff on this issue but never succeeded until I took a chance on this kinky piece of code:


It is also mentioned in other threads, but sometimes things are hard to find, though ;)

I did get this piece running within about 20 minutes - so give it a try ... In order to get it running with Access 2003 just export the classes, then import them into your project. You might have to change the two declarations

Dim objFTP As InetTransferLib.FTP
Set objFTP = New InetTransferLib.FTP

into

Dim objFTP As FTP
Set objFTP = New FTP

Then apply your parameters instead of those default ones - voila ...

That should do it for a good start :)

Hope some ppl might spare some time through this, since this stuff cost me a good half day ;) And of course a lot of thanks and credits to Dev Ashish and Terry Kreft for providing the code for free!!!

Have phun,
mutex7c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top