I'm using the following code and most of the time it works really well:
Set scpsession = New WinSCPnet.session
Set scpsessionOptions = New WinSCPnet.sessionOptions
Set scptransferOptions = New WinSCPnet.transferOptions
Log "After session create"
Select Case UCase(strDetailList(0))
.Protocol = Protocol_Ftp
'Log "FTP protocol selected"
.Protocol = Protocol_Sftp
'Log "SFTP protocol selected"
.HostName = strDetailList(1)
Log "Hostname set"
.UserName = strDetailList(2)
Log "Username set"
.Password = strDetailList(3)
'Log "Password set"
'.SessionLogPath = "c:\winscp.net"
'Log "Log path set"
.PortNumber = strDetailList(4)
Log "Port set"
Sometimes I get a connection error on the .password = strdetaillist(4) line. I don't understand why I would get a connection error because I don't think the connection is started until the line scpsession.Open scpsessionOptions?