+ Reply to Thread
Results 1 to 9 of 9

FTP File Download Through VBA

  1. #1
    Registered User
    Join Date
    01-06-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    FTP File Download Through VBA

    Hello fellow experts!

    I'm in desparate need of help. I am currently working on importing/exporting files to a ftp server.

    Now, I was able to successfully automate the send process. However, i'm having trouble automating the download process.

    What I mean by this is, on the ftp server there's an export folder that a client will put some csv files every night. The next morning I want to download these files from the ftp server onto my hard drive, I want to be able to automate this so that when I come in the morning they will be already copied to a folder on my hard drive.

    Now, the tricky part is that the filename is never the same since each filename has a time stamp (date, time, second...etc). I want to be able to transfer all files no matter what there name is.

    I used the following codes from a useful site: But, it's good for transferring 1 file that has a fixed name (in the example below "Picture.gif". In my case, I need to transfer a bunch of csv files that will always have different names, how do I work around this?

    Please Login or Register  to view this content.

    Thanks for any tips and advise as I spent lots of time searching on the net and didn't come up with any answers.
    Last edited by DavoH; 01-06-2011 at 10:34 PM. Reason: Added codes.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: FTP File Download Through VBA

    Hi DavoH

    Welcome to the Forum

    Please wrap your code in code tags, before the moderators get you...

    Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.

    Cheers

  3. #3
    Registered User
    Join Date
    01-06-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: FTP File Download Through VBA

    Thanks man! That was close lol.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: FTP File Download Through VBA

    Please Login or Register  to view this content.

    1. change the directory in which you want the downloaded files to be stored.
    2. adapt the path where you want to store the ftp file
    3. replace 'username' by your username for this ftp-server
    replace 'password' by your password for this ftp-server
    change '/httpdosc/...' in the directory where the to be downloaded files reside.
    change '*xls' by the extension of the files you want to download.
    4. adapt the ftp-files path according to step 2
    5. replace 'website.com' by the name of the ftp-server
    Last edited by snb; 01-07-2011 at 05:35 AM.



  5. #5
    Registered User
    Join Date
    01-06-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: FTP File Download Through VBA

    Thanks very much for your help snb! I tried your code above and encountered a problem regarding the following line:

    Please Login or Register  to view this content.
    When Shell was running I looked at the DOS prompt and saw 'invalid command' for the above line (** /Production/Export).

    The files I want to download reside on the server under a folder Production and a sub folder Export eg. ftpwebsite.com/Production/Export

    What am I doing wrong here?

    Thanks!

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: FTP File Download Through VBA

    This forum's software is so kind to change c_d (without underscore) into **

    you have to use (without underscore):

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-06-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: FTP File Download Through VBA

    I changed it to "c_d /Production/Export" (without underscore), no errors now in the prompt, but the process didn't work, the files di not get transferred

  8. #8
    Registered User
    Join Date
    07-02-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: FTP File Download Through VBA

    im unable to connect server, please help me to upload file to ftp.
    ftp> Not connected.
    ftp> USER xxxx
    Invalid command.
    ftp> xxxx
    Not connected.
    ftp> cd \upload\pickup
    Not connected.
    ftp> put D:\vba\practice_5_03\1.xlsx
    quit
    im gettin this error in temp files

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: FTP File Download Through VBA

    sujith,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1