Excel vba winscpnet.dll does not have open command in session object

Advertisement

DaveBrower
Joined:
Posts:
2
Location:
Calabasas

Excel vba winscpnet.dll does not have open command in session object

I'm trying to access files from an FTP site using Excel VBA. I have used WinSCP to get the parameters for sftp protocol used in the code below. I have successfully registered the dll file listed below. The code below works until I get to the open command. There is no open command within the session object. That is my problem.

I can launch Winscp.exe successfully from Excel VBA. I got the open parameters (protocol, name, etc) from WinSCP. The code below executed successfully until we get to the mysession.open.

Dim tmp1 As Variant
 
tmp1 = VBA.Shell("c:\Program Files (x86)\winscp\winscp.exe", vbNormalFocus)
Stop
    With MysessionOptions
        .Protocol = WinSCPnet.Protocol_Sftp
        .HostName = "sftp.datashop.livevol.com"
        .UserName = "dbrower9_ix_netcom_com"
        .Password = "Davyb002##"
        .SshHostKeyFingerprint = "ssh-rsa 2048 4yK/0LgwT2ERct0jZXdP6590zT9Qdhv78xfjWdv91lQ="
        .SshPrivateKeyPath = "C:\MyKeys\MyPrivateKey.ppk"
    End With
 
    ' Connect
    mySession.Open (MysessionOptions)
 
    ' Your code
Stop 
End Sub
I don't know how to insert a screen shot here, but the object browser shows these items under winscpnet: Failed, FileTransferProgress, FileTransfered, OutputDataReceived, QueryReceived. There is no Open.

OS is: Windows 10 Home, version 1909
Winscp is 5.17.7
winscpnet.dll is 1.17.2.10640

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
34,147
Location:
Prague, Czechia

Re: Excel vba winscpnet.dll does not have open command in session object

WinSCP .NET assembly does not expose its methods (for IDE) as it uses IDispatch interface. None of them, not only the Open. So that's probably not your problem.

This is wrong:
mySession.Open (MysessionOptions)
Remove the brackets.

This also looks suspicious: WinSCPnet.Protocol_Sftp
See https://winscp.net/eng/docs/library_vb#enums

Reply with quote

DaveBrower

Re: Excel vba winscpnet.dll does not have open command in session object

Please forgive me. I don't understand how to access the WinSCP objects, if they are not exposed when I register WinSCPnet.dll. What is this dll file for, if it does not expose the Open (and other) methods? It clearly exposes many methods, but not the ones I need. Sorry for my ignorance.

Reply with quote

martin
Site Admin
martin avatar

Re: Excel vba winscpnet.dll does not have open command in session object

They are not exposed for enumeration by the IDE. But they can be invoked. Again, the subject of this topic is not your problem. Your problem is in your code.

Reply with quote

Advertisement

You can post new topics in this forum