title: VBA download file from FTP url
body: <p>Im trying to create VBA code to download a file to specific path from direct FTP link (asynchronously preferred).
  I only found code for making it work with http urls, but for FTP i get this error:</p>
  
  <p>"Run-time error '-2146697210 (800c0006)':
  The system cannot locate the object specified"</p>
  
  <p>For these first testing have not set username or password for the ftp-server.</p>
  
  <p>My code which is working only for http is below:</p>
  
  <pre><code>Sub DownloadFile()
  
  Dim myURL As String
  myURL = "ftp://xxx.xxx.xxx.xxx/test.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 "C:\FTP\file.txt", 2 ' 1 = no overwrite, 2 = overwrite
      oStream.Close
  End If
  
  End Sub
  </code></pre>