Excel 无法使用“连接到FTP服务器”;wininet.dll“;在VBA中,但可以与WinSCP连接
我使用下面的代码片段在VBA中使用Excel 无法使用“连接到FTP服务器”;wininet.dll“;在VBA中,但可以与WinSCP连接,excel,vba,ftp,winscp,wininet,Excel,Vba,Ftp,Winscp,Wininet,我使用下面的代码片段在VBA中使用wininet.dll连接到服务器,但无法连接到该服务器。但是,当我尝试使用WinSCP5.15.1连接到服务器时,它能够连接。当我尝试使用WinSCP的5.5.5.0版本时,它显示错误“无法同意密钥交换算法”。 当我尝试使用cmd中的ftp命令连接时,它还显示登录错误 我想知道是否可以通过修复任何东西,在VBA中使用wininet.dll连接到服务器 Public Function checkFTPpath(ByVal ServerName, ByVal Us
wininet.dll
连接到服务器,但无法连接到该服务器。但是,当我尝试使用WinSCP5.15.1连接到服务器时,它能够连接。当我尝试使用WinSCP的5.5.5.0版本时,它显示错误“无法同意密钥交换算法”。
当我尝试使用cmd
中的ftp
命令连接时,它还显示登录错误
我想知道是否可以通过修复任何东西,在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
如果您在WinSCP中得到“无法同意密钥交换算法”,则表示您使用的是SFTP协议,而不是FTP。Wininet只讲FTP,不讲SFTP
您必须使用SFTP库。请参阅。我只需要检查特定路径是否存在。您能给我建议一下签入VBA的最佳方法吗?我已经回答了您关于“无法在VBA中使用“wininet.dll”进行连接”的问题。如果您现在有新问题,请发布新问题。