I'm trying to connect to an SFTP directory using VBA within Excel. I would like to drop off and retrieve files from the directory. Currently I do this by dragging/dropping with Filezilla, but I'd like to see if I can achieve this using VBA so that users do not have to exit Excel and can send/retrieve files to/from the remote directory without having to leave Excel and go to Filezilla.
I tried using some VBA with putty's PCSP.exe tool but had no joy. I tried to adapt the code below that I found elsewhere.
Public Sub SftpPut()
Const cstrSftp As String = """U:\putty\pscp.exe"""
Dim strCommand As String
Dim pUser As String
Dim pPass As String
Dim pHost As String
Dim pFile As String
Dim pRemotePath As String
pUser = "---"
pPass = "---"
pHost = "---"
pFile = "C:\Access\sample.txt"
pRemotePath = "/home"
strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & _
" " & pFile & " " & pHost & ":" & pRemotePath
Debug.Print strCommand
Shell strCommand, 1 ' vbNormalFocus '
End Sub
When using Filezilla, I login with a User ID and a .ppk Key File, I can't see how to use the Key File with the above.
Can anybody assist? Many Thanks.