FTP multiple Files

Rajgupta

New member
Local time
Yesterday, 20:00
Joined
Dec 31, 2007
Messages
1
Hi,

I am trying to ftp multiple files into my local drive using access macro but I am unable to do it.

I am using ftpGetFile from wininet.dll to copy the file. But it seems that this particular function can copy only one file and that too with the name's specified.
I tried using wild characters but it didn't work.

Can anyone has an alternative.

Thanks
rajesh

Here's what my code looks like

Following goes into the class module
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean


And we are using following function to copy the file:

Function CopyFtpFile(strFtpServer As String, strFtpUsername As String, strFtpPassword As String, _
strFtpFile As String, strTargetSpec As String) As Long

Dim L As Long
Dim dwIntError As Long, dwLength As Long
Dim strBuffer As String

On Error GoTo Err_CopyFtpFile
' Open Internet session

L = wininet_InternetOpen()
If L <> 0 Then Error L
' Open Internet connection to FTP server
L = wininet_InternetConnect(strFtpServer, strFtpUsername, strFtpPassword)
If L <> 0 Then Error L
' Attempt to get FTP file
L = wininet_FtpGetFile(strFtpFile, strTargetSpec)

If L <> 0 Then Error L
L = 0
End_CopyFtpFile:
' Close connection
wininet_InternetDisconnect
' Close session

wininet_InternetClose
CopyFtpFile = L
Exit Function

Err_CopyFtpFile:
If L = ERROR_INTERNET_EXTENDED_ERROR Then
InternetGetLastResponseInfo dwIntError, vbNullString, dwLength
strBuffer = String(dwLength + 1, 0)
InternetGetLastResponseInfo dwIntError, strBuffer, dwLength
MsgBox "Error " & L & "/" & dwIntError & ":" & vbCrLf & _
strBuffer, vbExclamation, "Copy from FTP Failed"
Else
MsgBox "Error " & L, vbExclamation, "Copy from FTP Failed"
End If
Resume End_CopyFtpFile
End Function



Module level Call is
Call oftp.CopyFtpFile("aixapac1", "kroger", "kroger123", _
"/projects5/kroger/temp-GAPCIORP/SBC.txt" , "C:\SBC.txt")

In the above call I tried using wild characters but it didnt work.
 

Users who are viewing this thread

Back
Top Bottom