我正在使用下面的代码段通过VBA中的“ wininet.dll”连接到服务器,但无法连接到该服务器。但是,当我尝试使用WinSCP 5.15.1连接到服务器时,它就可以连接。并且当我尝试使用WinScp 5.5.5.0版本时,它显示错误“不同意密钥交换算法”。当我尝试使用ftp
中的cmd
命令连接它时,它还会显示登录错误。
我想知道是否有可能通过修复任何问题使用VBA中的“ wininet.dll”连接到服务器。
Public Function checkFTPpath(ByVal ServerName, ByVal Username, ByVal password, ByVal remote_path) As Boolean
Dim hostFile As String
Dim INet As Long
Dim INetConn As Long
Dim RetVal As Long
Dim Success As Boolean
Success = False
RetVal = False
INet = InternetOpen("MyFTP Control", 1&, vbNullString, vbNullString, 0&)
If INet > 0 Then
INetConn = InternetConnect(INet, ServerName, 21, Username, password, 1&, 0&, 0&)
If INetConn > 0 Then
Success = FtpSetCurrentDirectory(INetConn, "/")
Success = FtpSetCurrentDirectory(INetConn, remote_path)
RetVal = InternetCloseHandle(INetConn)
End If
RetVal = InternetCloseHandle(INet)
End If
checkFTPpath = Success
End Function
speaks仅FTP,而不是SFTP。您将必须使用SFTP库。参见SFTP upload in VBA。