DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: downloading changing txt file from ftp

  1. #1
    Join Date
    Feb 2011
    Posts
    7

    downloading changing txt file from ftp

    Hi all, I am having hard time putting this together.. Was hoping someone would be able to help.

    is there a way to set up a macro in excel VBA to download a txt file where the filename changes based on the business day? The only thing that would change is the date..I need to download daily files for previous business day in a shared drive
    so for example, for 15th I would download the file: "name_02142011"

    I have the ftp details, but also looking to download the file on a shared drive

    Any help would be greatly appreciated

    Thanks so much

    Danny

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Play around with this
    Code:
    Private Sub CommandButton1_Click()
    Dim iDay As Integer
    Dim sFTPName As String
    iDay = Day(Now) - 1
    sFTPName = "name_" & Format(Month(Now), "00") & iDay & Year(Now)
    MsgBox sFTPName
    End Sub

  3. #3
    Join Date
    Feb 2011
    Posts
    7
    Thanks Hack.. I am working with below code to pull FTP data.. Would you mind taking a peek to see what I did wrong? I am getting an error on EXECUTE command
    Thanks so much

    Sub Download_BR()
    Dim i_ftp As inet
    Set i_ftp = New inet

    With i_ftp
    .URL = "ftp://servername/files/"
    .UserName = "1234"
    .Password = "5678"
    .Execute , "GET files/info.txt G:\transfered_files\info.txt"
    End With

    Set i_ftp = Nothing 'this will not finish until xfer is complete.
    'so ... one you're here you know the xfer is complete

    End Sub

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What error are you getting?

  5. #5
    Join Date
    Feb 2011
    Posts
    7
    no error at all. the code runs through with no errors but when I check the shared drive, the file is not downloaded from FTP.. am I missing something in my code?

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    If you are not getting an error then what did you mean by this?
    Quote Originally Posted by donyc View Post
    I am getting an error on EXECUTE command
    Try putting a break on your sub and stepping through it.

  7. #7
    Join Date
    Feb 2011
    Posts
    7
    sorry..lack of sleep...got confused with all these different macros..

    I get VB popup "Class does not support Automation or does not support expected interface" and higlights below in VBA

    Set i_ftp = New inet

  8. #8
    Join Date
    Feb 2011
    Posts
    7
    Hi Hack, I am back.... I downloaded the MSINET.OCX file again and it seems it got rid of error 430.. but now I am getting same break as before on Execute

    I get Run-time error '35754' Unable to connect to remote host and it when I debug it higlights:
    .Execute , "GET files/info.txt G:\transfered_files\info.txt"

    You mentioned earlier try to put a break on it..not sure what do you mean? Would you mind explaining?

    Thanks so much

Similar Threads

  1. Making a dynamic txt file name
    By danw8 in forum VB Classic
    Replies: 3
    Last Post: 04-22-2008, 08:16 AM
  2. Replies: 2
    Last Post: 02-11-2008, 05:12 PM
  3. Copying data from one txt file to another
    By mp_direct in forum VB Classic
    Replies: 1
    Last Post: 11-05-2005, 04:28 PM
  4. FTP connection and ZIP file
    By kash in forum Java
    Replies: 0
    Last Post: 08-22-2002, 09:38 PM
  5. FTP API Get file createdate
    By Duane in forum VB Classic
    Replies: 0
    Last Post: 11-07-2001, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center