title: SFTP Upload from MS-Access using VBA and WINSCP
body: <p>please see code below, this was pulled from another site and i amended with my details. i am trying to run an automatic upload to my SFTP site based on a trigger event. for some reason, it is not working. please let me know if there are any issues with what i have done. code debugger from immediate window is found below.</p>
  
  <pre><code>Private Sub Form_Close()
  
    Const CMD_WINSCP As String = _
      "WinSCP.com /Command ""open sftp://user:password@server/ -hostkey=""""fingerprint"""""" ""put local remote"" ""exit"""""
  
    Dim User As String
    Dim Password As String
    Dim Fingerprint As String
    Dim LocalFile As String
    Dim RemotePath As String
    Dim Command As String
    Dim Server As String
  
    'TODO: Initialize parameters.
    User = "Inarion"
    Password = "pwd123"
    Fingerprint = "CopiedFromGenerateSessionURLCodeSSHHostKey"
    LocalFile = "c:\users\myname\path\filename.csv"
    RemotePath = "stackoverflow.com/users/path/"
    Server = "999.999.999.999.sftp.stackoverflow.com" ' IPv4 should work as well
  
  
    Command = CMD_WINSCP
    Command = Replace(Command, "user", User)
    Command = Replace(Command, "password", Password)
    Command = Replace(Command, "fingerprint", Fingerprint)
    Command = Replace(Command, "local", LocalFile)
    Command = Replace(Command, "remote", RemotePath)
    Command = Replace(Command, "server", Server)
    Debug.Print Command
    Shell Command
  
  from Immediate window:
  WinSCP.com /Command "open sftp://Inarion:pwd123@999.999.999.999.sftp.stackoverflow.com/ -hostkey=""CopiedFromGenerateSessionURLCodeSSHHostKey""" "put c:\users\myname\path\filename.csv sftp.stackoverflow.com/users/path/" "exit""
  </code></pre>