Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


@Ian – you might want to reconsider the use of the VBScript call given Microsoft's plans to depreciate and eventually remove VBScript.

So far I have managed to use CreateProcessA instead, assuming that won't be affected in the same way... As opposed to using a Shell command, CreateProcessA does have options to wait until completed.

More information on it and waiting to finish is here:

WinSCP from MS Access

I have a need to create a facility for a small number of Access users to upload to a central server pdf files.
Having searched the web WinSCP seems to be the most prefered option.

I found a small bit of code, which, I think, Martin wrote in Jan 2023
Using VBA to run WinSCP script
I like this small and compact procedure, and use it in my own projects. No temp-files required. Fast and reliable.
Sub uploadImageByFTP(src As String)
    Dim script As Object: Set script = VBA.CreateObject("WScript.Shell")
    Dim waitOnReturn As Boolean: waitOnReturn = True
    Dim windowStyle As Integer: windowStyle = 1
    'Not empty
    If (src <> vbNullString) Then
       'Execute script
        script.Run _
            """< path>"" " + _
            "/ini=nul " + _
            "/command " + _
            """open ftp://<username>:<password>@<hostname>/"" " + _
            """cd <FTP-path>"" " + _
            """put " & """""" & src & """""" & """ " + _
            """close"" " + _
            """exit""", windowStyle, waitOnReturn
    End If
End Sub

It looks perfect, however, when I copied the code into a test access form and ran it, I got an error.
Procedure declaration does not match description of event or procedure having same name

At my current level of expertise and experience, I am afriad this error is beyond me. Can you ppint me in the right direction pleqse.