LeighWardle
asked on
Access 2016 VBA code to upload a file to a FTP server
Hi Experts,
I'm looking for code or a package that can be called from Access 2016 VBA code to upload a file to a FTP server.
Thanks,
Regards,
Leigh
I'm looking for code or a package that can be called from Access 2016 VBA code to upload a file to a FTP server.
Thanks,
Regards,
Leigh
https://dbwiki.net/wiki/VB A_Tipp:_Da tei-Downlo ad_und_-Up load_(FTP)
Sample VBA source for using wininet.dll for FTP.
CreateDirectory is missing
HTH
Sample VBA source for using wininet.dll for FTP.
CreateDirectory is missing
Private Declare Function FtpCreateDirectory Lib "wininet.dll" _
Alias "FtpCreateDirectoryA" ( _
ByVal hConnect As Long, _
ByVal lpszDirectory As String) As Bool
Haven't tested the code ...HTH
Well i just tested this:
1 Download from here the beta TransferLibrary
2. extract from the zip the .dll and place it in SysWOW64
3. Open your Access Application and reference the .dll -->Tools -->References --> Browse find the above .dll
4 the code provided originally needs a bit of tweaking ....this below works
1 Download from here the beta TransferLibrary
2. extract from the zip the .dll and place it in SysWOW64
3. Open your Access Application and reference the .dll -->Tools -->References --> Browse find the above .dll
4 the code provided originally needs a bit of tweaking ....this below works
Public Function FtpUpload()
Dim objFTP As InternetTransferLib.FTP
Dim ftpURL As String
Dim ftpUser As String
Dim ftpPassword As String
Dim ftpDirectory As String
Dim sourceFile As String
Dim destinationFileName As String
ftpURL = "YOUR FTP"
ftpUser = "FTP USER NAME"
ftpPassword = "FTP PASSWORD"
ftpDirectory = " THE NAME OF THE DIRECTORY"
sourceFile = "Complete Path of the File" 'e.g C:\Temp\Somefile.txt
destinationFileName = "The Name of the File on the FTP " 'e.g Somefile.txt
Set objFTP = New InternetTransferLib.FTP
With objFTP
.Connect ftpURL, True, ftpUser, ftpPassword
.CreateDirectory ftpDirectory
.ChangeDirectory ftpDirectory
.Upload ITL_INTERNET_FLAG_TRANSFER_BINARY, sourceFile, destinationFileName, True
End With
End Function
ASKER
Hi John,
Your code looks promising!
Will it create a subfolder on the FTP server, if it does not already exist?
Regards,
Leigh
Your code looks promising!
Will it create a subfolder on the FTP server, if it does not already exist?
Regards,
Leigh
The code does exactly what you need ...creating a non existed directory...tested and working fine..
Be aware that the other technique of doing FTP is simply to execute a batch file that you write out with Shell() against a FTP client you have installed.
With this, you can use a number of FTP clients depending on your need. For example, I have one client that makes use of the Microsoft FTP client, one from MoveIT, and WinSCP.
Jim.
With this, you can use a number of FTP clients depending on your need. For example, I have one client that makes use of the Microsoft FTP client, one from MoveIT, and WinSCP.
Jim.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks John - all working in production mode.
Regards,
Leigh
Regards,
Leigh
ASKER