Hi everyone,
I am wondering if someone can help me with a challenge that I am facing right now I have been trying to come up with a solution for the past 3 days with no success. Basically what I am trying to accomplish is uploading multiples file automatically into server. The code I am trying to use is the one from Dev Ashish that can be found in his website "Sorry, this is my first post and I couldn't post the link here". The code works great if the user wants to upload a single file manually because the code prompts you to choose the file and I am wondering if there is a way to tweak the code.
here is the code I am using
the code that needs to be tweaked is the one below
whenever I try to run the code it will display error 53 File not found
.SourceFile = strfile
thanks
I am wondering if someone can help me with a challenge that I am facing right now I have been trying to come up with a solution for the past 3 days with no success. Basically what I am trying to accomplish is uploading multiples file automatically into server. The code I am trying to use is the one from Dev Ashish that can be found in his website "Sorry, this is my first post and I couldn't post the link here". The code works great if the user wants to upload a single file manually because the code prompts you to choose the file and I am wondering if there is a way to tweak the code.
here is the code I am using
Code:
Private Sub Form_Load()
Dim objFTP As FTP
Dim strfile As String
strfile = Dir("C:\Documents and Settings\%username%\My Documents\TEST1" & "\" & "*.txt")
Const conTARGET = "ftp://servername.com"
Do While Len(strfile) > 0
Set objFTP = New FTP
With objFTP
.FtpURL = conTARGET
.SourceFile = strfile
.DestinationFile = "/TEST/" & strfile
.AutoCreateRemoteDir = True
If Not .IsConnected Then .DialDefaultNumber
.ConnectToFTPHost "username", "password"
.UploadFileToFTPServer
strfile = Dir
End With
Loop
End Sub
the code that needs to be tweaked is the one below
Code:
Public Property Let SourceFile(strFilename As String)
'Pass vbNullString for Common Dialog
If strFilename = vbNullString Then
If lnghWnd = 0 Then lnghWnd = apiGetActiveWindow()
mstrSrcFile = fGetNewFileName("Please select the" _
& " file to upload.", lnghWnd, True)
Else
mstrSrcFile = strFilename
End If
mblnUpload = True
mlngSize = FileLen(mstrSrcFile)
End Property
whenever I try to run the code it will display error 53 File not found
.SourceFile = strfile
thanks
Last edited: