Hi,
I need to copy to and from an ftp server - from Access.
I checked the site and found some helpfull posts.
So, I added and Inet control to a form and used the following code (sorry I do not remember from whom I took it).
Private Sub Command0_Click()
SetUpftp
DownloadFile
End Sub
Private Sub SetUpftp()
Inet1.AccessType = icUseDefault
Inet1.URL = "ftp://" & IPAddress & "/"
Inet1.UserName = "user"
Inet1.Password = "Password"
Inet1.RequestTimeout = 40
End Sub
Private Sub DownloadFile()
Dim lStr_ServPathName As String
Dim lStr_NewPathName As String
Dim lStr_ftpCommand As String
Dim lStr_ftpComment As String
lStr_ServPathName = "\folder1\fileToGet.txt"
lStr_NewPathName = "c:\fileToGet.txt"
lStr_ftpComment = "GET " & lStr_ServPathName & " " & lStr_NewPathName
ExecuteftpCommand lStr_ftpCommand
End Sub
Private Sub ExecuteftpCommand(rStr_ftpCommand As String)
On Error Resume Next
Inet1.Execute , rStr_ftpCommand
While Inet1.StillExecuting
DoEvents
Wend
End Sub
Private Sub Inet1_StateChanged(ByVal rInt_ftpState As Integer)
Dim lStr_ErrorMsg As String
Select Case rInt_ftpState
Case icError
lStr_ErrorMsg = "Code: " & Inet1.ResponseCode & " : " & Inet1.ResponseInfo
MsgBox lStr_ErrorMsg
'Inet1.Cancel
Case icResponseCompleted
MsgBox "ftp Operation Complete"
Case icNone
Case icResolvingHost
Case icHostResolved
Case icConnecting
Case icConnected
Case icRequesting
Case icRequestSent
Case icReceivingResponse
Case icResponseReceived
Case icDisconnecting
Case icDisconnected
End Select
End Sub
Result : No error message, but the file (fileToGet.txt) does not appear on my C:\ drive !
(Message "ftp Operation Complete" appears).
I tried it the other way around, with the "PUT" command - with no success either !
What am I doing wrong ?
Thank you !
I need to copy to and from an ftp server - from Access.
I checked the site and found some helpfull posts.
So, I added and Inet control to a form and used the following code (sorry I do not remember from whom I took it).
Private Sub Command0_Click()
SetUpftp
DownloadFile
End Sub
Private Sub SetUpftp()
Inet1.AccessType = icUseDefault
Inet1.URL = "ftp://" & IPAddress & "/"
Inet1.UserName = "user"
Inet1.Password = "Password"
Inet1.RequestTimeout = 40
End Sub
Private Sub DownloadFile()
Dim lStr_ServPathName As String
Dim lStr_NewPathName As String
Dim lStr_ftpCommand As String
Dim lStr_ftpComment As String
lStr_ServPathName = "\folder1\fileToGet.txt"
lStr_NewPathName = "c:\fileToGet.txt"
lStr_ftpComment = "GET " & lStr_ServPathName & " " & lStr_NewPathName
ExecuteftpCommand lStr_ftpCommand
End Sub
Private Sub ExecuteftpCommand(rStr_ftpCommand As String)
On Error Resume Next
Inet1.Execute , rStr_ftpCommand
While Inet1.StillExecuting
DoEvents
Wend
End Sub
Private Sub Inet1_StateChanged(ByVal rInt_ftpState As Integer)
Dim lStr_ErrorMsg As String
Select Case rInt_ftpState
Case icError
lStr_ErrorMsg = "Code: " & Inet1.ResponseCode & " : " & Inet1.ResponseInfo
MsgBox lStr_ErrorMsg
'Inet1.Cancel
Case icResponseCompleted
MsgBox "ftp Operation Complete"
Case icNone
Case icResolvingHost
Case icHostResolved
Case icConnecting
Case icConnected
Case icRequesting
Case icRequestSent
Case icReceivingResponse
Case icResponseReceived
Case icDisconnecting
Case icDisconnected
End Select
End Sub
Result : No error message, but the file (fileToGet.txt) does not appear on my C:\ drive !
(Message "ftp Operation Complete" appears).
I tried it the other way around, with the "PUT" command - with no success either !
What am I doing wrong ?
Thank you !