problems automating ftp file download

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


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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
can you not use the code to create a dos batch job to do one transfer, logout , then fire off the second one

you can create the dos batch file and execute it from your VBA and wait for completion before moving on the next step
 
Upvote 0
jim

sorry for my late reply but i got very busy that day and have since come down with a bug!! (me not my computer)

it all looks a bit complicated but i'll try and give things a read over as soon as possible, to be honest i'm not familiar with batch files at all.

Thank you for your reply!

jon
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,634
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top