Search code examples
ms-accessftpvbawinscp

MS Access VBA get result of WinSCP transfer


I have code that uploads a folder to an FTP server using WinSCP.

Dim strSFTPDir As String
strSFTPDir = "C:\Program Files (x86)\WinSCP\"
Dim UploadsDir As String
UploadsDir = DLookup("PathToPics", "Admin") & "\Uploads\*"
Call Shell(strSFTPDir & "winscp.com /command ""open ftp://***/"" ""put -filemask=|*.ldb """"" & UploadsDir & """"" "" ""exit"" ", vbNormalFocus)

However I need to let Access know whether it's succeeded or failed. How can I do that?


Solution

  • WinSCP indicates a result with its exit code.
    See WinSCP FAQ How do I know that script completed successfully?

    So run WinSCP and make sure it returns 0 (success).
    See VBA Shell and Wait with Exit Code