1

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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Tristan King
  • 97
  • 13

1 Answers1

2

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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks for the answer, but the code in that link is long and confusing and I'm not sure what parts exactly I need? Does my original Call Shell() code need to be changed entirely? – Tristan King Nov 28 '18 at 13:33
  • You need to replace your `Shell` call with what the `RunApplication` function does in the linked code. There's no easier way in VBA. - If you do not explain us, what you find *"confusing"* about the code, we cannot help you on that. – Martin Prikryl Nov 28 '18 at 13:52