-
Connecting & Downloading via FTP
Hi,
I need to connect to an FTP server and download a file from a specified location. I wrote some VBA code which unfortunately does not work. But it generates a script file - which if I copy into ftp .exe, it works.
Your help will be appreciated. Thanks!
Nitin
PS: Here's my code.
[VBA]Sub Macro1()
fNum = FreeFile()
Open ThisWorkbook.Path & "\FtpComm.txt" For Output As #fNum
Print #1, "open ftp .site .com" '' I've added spaces here coz it doesnt let me post links
Print #1, "usename"
Print #1, "password"
Print #1, "recv triala" ' close connection
Print #1, "bye" ' Quit ftp program
Close #1
Shell "ftp -s:" & ThisWorkbook.Path & "\FtpComm.txt ", vbNormalNoFocus
'Shell "ftp -n -i -g -s:" & file & vFTPServ, vbNormalNoFocus
End Sub[/VBA]
-
Welcome to the forum. Please edit your post and add code tags around your code.
A method that is a bit easier can be seen here. http://vbaexpress.com/forum/showthread.php?t=960
-
Another working FTP example is posted at http://www.vbaexpress.com/forum/showthread.php?t=16836 from about a year ago. The articles referenced in the third post give some insight into what else you can do with what's there. Obviously there is plenty of room to tweak and condense the code; I tried to make it as clear as possible, which doesn't make for compact.
Hope that helps,
G.T.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules