I am trying to use this FTP Access example. It works GREAT for single files. But I need to copy the entire folder down. Does anyknow know how to do that in a command line?
The demo is here...
http://www.databasejournal.com/features/msaccess/article.php/3513061I think the change needs to be made in here...
Public Function DownloadFTPFile(ByVal sFile As String, sSVR As String, sFLD As String, sUID As String, sPWD As String) As String
Dim sLocalFLD As String
Dim sScrFile As String
Dim sTarget As String
Dim iFile As Integer
Dim sExe As String
Const q As String = """"
On Error GoTo Err_Handler
DoCmd.Hourglass True
sLocalFLD = CurrentProject.Path & "\" & sFLD
' will break if empty folder exist so error to pass
' must create folder first, so API calls work
On Error Resume Next
If Dir(sLocalFLD & "\") = "" Then MkDir (sLocalFLD)
On Error GoTo Err_Handler
sScrFile = sLocalFLD & "\download.scr"
If Dir(sScrFile) <> "" Then Kill sScrFile
sTarget = q & sLocalFLD & "\" & sFile & q
Debug.Print "Target:" & sTarget
sFile = q & sFile & q
Debug.Print "Folder: " & sFLD 'sFile
' Open a new text file to hold the FTP script and load it with
' the appropriate commands. (Thanks Dev Ashish !!!)
iFile = FreeFile
Open sScrFile For Output As iFile
Print #iFile, "open " & sSVR
Print #iFile, sUID
Print #iFile, sPWD
Print #iFile, "cd " & sFLD
Print #iFile, "binary"
Print #iFile, "lcd " & q & sLocalFLD & q
'Print #iFile, "get " & sFile & " " & sTarget 'gets one file
Print #iFile, "mget " & sFile & " " & sTarget 'sFile & " " & sTarget
'*******************I changed to mget from get to try and get the entire folder
Print #iFile, "bye"
Close #iFile
sExe = Environ$("COMSPEC")
sExe = Left$(sExe, Len(sExe) - Len(Dir(sExe)))
sExe = sExe & "
ftp.exe -s:" & q & sScrFile & q 'just one file
ShellWait sExe, vbHide
DoEvents
Exit_Here:
DownloadFTPFile = GetFileText(sScrFile)
DoCmd.Hourglass False
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "E R R O R"
Resume Exit_Here
End Function
Thank you in advance.
Start Free Trial