berlinhammer
Board Regular
- Joined
- Jan 30, 2009
- Messages
- 187
Hello
I have two files that I wish to download from a set FTP each day. Each file is under a different user account, therefore necessitating a username and password for each download.
The below code seems to work ok for one user and not the other, it works if 'already' logged in but won't seem to accept the new password when I try to run it as the second user.
Why won't it accept the new password??
I'd be very grateful for any help as I'm inexperienced with FTP and finding this rather difficult!!
Thankyou
Jon
I have two files that I wish to download from a set FTP each day. Each file is under a different user account, therefore necessitating a username and password for each download.
The below code seems to work ok for one user and not the other, it works if 'already' logged in but won't seem to accept the new password when I try to run it as the second user.
Why won't it accept the new password??
I'd be very grateful for any help as I'm inexperienced with FTP and finding this rather difficult!!
Thankyou
Jon
Code:
Sub test()
Dim ftpaddress, username, password, fdate, ftype, fext, fname, fpath As String
ftpaddress = "wherever"
username = "user"
password = "whatever"
fdate = Format(Date - 1, "yyyymmdd")
ftype = "XNAV"
fext = "csv"
fname = fdate & "_" & ftype & "." & fext
fpath = "ftp://" & username & ":" & password & "@" & ftpaddress & "/" & fname
Workbooks.Open Filename:=fpath
Workbooks(fname).Close
End Sub