Sub CommandButton2_Click()
Dim myURL As String
myURL = "ftp://11.11.11.11/sample/myfile.txt"
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False, "username", "password"
WinHttpReq.send
myURL = WinHttpReq.responseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.responseBody
oStream.SaveToFile "D:\FTPFOLDER\file.txt", 2
oStream.Close
MsgBox "success"
Else
MsgBox "not success"
MsgBox WinHttpReq.Status
End If
End Sub
我尝试了上面的VBA宏代码,它没有从FTP URL下载文件。 但是它没有显示任何错误。我需要安装的任何插件/需要提供的任何访问权限。是否添加/包括任何引用。任何人都有任何想法
注意:通过Filezilla,我可以上传和下载文件