WinSCP from MS Access

Advertisement

ianlowie@...
Guest

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 _
            """<WinSCP.com 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.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum