Looking for some simple code to list all file in a spesific ftp server directory.
Do you have some sort of FTP OCX installed on your system, providing VBA access to FTP capabilities?
I have a FTP Server containing files for diffrent Clients. I want to populate a listbox with all file names of the files on my server.
Just an FYI - VBA OCX objects are notorious for problems. That is why I suggest not using ActiveX controls unless you have absolutely no alternative. The reason is that the ActiveX controls need to be installed on every machine that uses them, and they aren't always there, so you need to have an installation routine. Also, Microsoft many times will do something like either remove them from Access or do some changes which require you to go scrambling for an alternative.Note: That one uses command injection to the ftp.exe program, which I would consider less reliable than using a VBA compatible OCX object.
FTPServerDir = "/wwwroot/ClientBE/"
FileNo = FreeFile
ChDir "C:\LabourSoft\Data\FTP\"
Open "ftp-cmd.txt" For Output As #FileNo
Print #FileNo, "open [URL="ftp://ftp.laboursoft.co.za"]ftp.laboursoft.co.za[/URL]"
Print #FileNo, "laboursoft.co.za"
Print #FileNo, "###Pass###"
Print #FileNo, "cd " & FTPServerDir
Print #FileNo, "ls - C:\LabourSoft\Data\FTP\ServerDir.txt"
Print #FileNo, "close"
Print #FileNo, "quit"
Close #FileNo
On Error Resume Next
Shell "[URL="ftp://ftp.exe"]ftp.exe[/URL] -s:ftp-cmd.txt", vbHide
Just an FYI - VBA OCX objects are notorious for problems. That is why I suggest not using ActiveX controls unless you have absolutely no alternative.
Hi Michael, kindly explain please