rcartner Absent Member.
Absent Member.

Automate FTP Connection with VBA


I have been trying to connect to some outside servers using VBA with Rumba FTP Client 4.4 but have been unable to successfully do so. I can create the connections using the GUI, but receive an error 500 when I try to do this with the same setting using VBA. 

Also, when I try to create a saved session, I receive the following error:

err.Description: "Automation error Unspecified error"

err.Number: -2147467259


Here is my code for trying to both connect and/or save:

Dim oFtpApp As FTPSFTPLib.SFtpApplication
Dim oFtpSession As FTPSFTPLib.SFtpSession
Dim nRC As Integer

Set oFtpApp = New FTPSFTPLib.SFtpApplication
Set oFtpSession = oFtpApp.newSession

oFtpSession.Hostname = "my host name" 
oFtpSession.UserName = "my user name"
oFtpSession.Password = "my password"
oFtpSession.ServerType = "UNIX"
oFtpSession.TransferType = "Auto Detect"
oFtpSession.Protocol = "SFTP"
oFtpSession.Port = "22"

nRC = oFtpSession.SaveSessionFileAs("testSessionConnection.sft")  ' NOTE: This will cause the Automation error Unspecified error

' Connect to the host session.
' --------------------------------------------------------------------------------------

nRC = oFtpSession.Connect
If (nRC <> 0) Then
  MsgBox nRC, vbExclamation + vbSystemModal, "Unsuccessful"


  MsgBox "Connection Successful", vbExclamation + vbSystemModal, "Successful"
End If



Again, this specific setting works when I create the session using the GUI, but not through VBA. Can anyone show me what I'm missing? 

Tags (2)
3 Replies
Micro Focus Expert
Micro Focus Expert

RE: Automate FTP Connection with VBA

can you try to use late binding when working with the FTP components ?
I'm attaching a working late binding example:



rcartner Absent Member.
Absent Member.

RE: Automate FTP Connection with VBA

Thank you for the replay. I just tried late binding with the same results. Trying to save the session file gave an "Automated Error" message. Trying to connect gives me a nRC = 500.
Micro Focus Expert
Micro Focus Expert

RE: Automate FTP Connection with VBA

I tested Rumba FTP 4.4 under Win10 with my posted code and it works without problem.
I'm using Excel VBA to run the code.
Can you please add oFtpSession.TraceLevel = 5 to your code ?
This line will add some logging to the ftp connection. Trace level 5 will add FTPEngine.log ,FTPSFTP.log and some RSSxxx.log files into your %temp% Directory.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.