Computer Hope

Software => Computer programming => Topic started by: ajetrumpet on November 02, 2009, 12:03:53 PM

Title: VBA programming with FTP sessions
Post by: ajetrumpet on November 02, 2009, 12:03:53 PM
hello all,

There is a problem I can't get my head around. I have this code for example:
Code: [Select]
      Dim vPath As String
      Dim vFTPServ As String
      Dim fNum As Long
     
      vPath = "C:"
      vFTPServ = "www.domain.com"
      fNum = FreeFile()
     
      Open vPath & "\FtpComm.txt" For Output As #fNum
      Print #1, "USER myUN" ' your login
      Print #1, "pass" ' your password
      Print #1, "dir " & Me.namefield & " c:\test.txt"
      Print #1, "close"
      Print #1, "quit"
      Close
     
      Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbHide
i am doing this everytime I want to view the contents of the TEST text file. my question is, is there a way that I can leave the FTP session open, and keep printing lines in the FTPCOMM file and keep executing DOS commands one at a time this way instead of opening and closing the connection each time?

I am getting a huge delay in updates when I run this procedure seperately evertime I want to update my interface with the DOS output, so if I can leave the session open I think I can completely eliminate the time I have to wait!  I am using VBA with Office 2003 and windows vista.  thanks all!
Title: Re: VBA programming with FTP sessions
Post by: gh0std0g74 on November 02, 2009, 05:08:35 PM
do you absolutely have to do this with VBA? you are using the wrong choice of tools to do FTP.
Title: Re: VBA programming with FTP sessions
Post by: ajetrumpet on November 02, 2009, 06:53:21 PM
i do need to do it in VBA, yes.  I searched for the INET active X, but apparently you have to pay to get it downloaded.  is that true?
Title: Re: VBA programming with FTP sessions
Post by: gh0std0g74 on November 02, 2009, 07:11:28 PM
i do need to do it in VBA, yes.  I searched for the INET active X, but apparently you have to pay to get it downloaded.  is that true?
I am not sure because I don't have to pay to do programming. If you are being forced to pay to program, then you are being ripped off. A lot of stuff to do programming are free. Perl/Python etc comes with excellent FTP libraries that makes your file transfer job easier. If you can find a library that you can use with VBA that is free, go ahead and use it.