View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
R. Choate R. Choate is offline
external usenet poster
 
Posts: 106
Default FTP in vba macro

I got an error on the Shell line. It shows in red in the editor so something
is missing or bad syntax. Could you give some explanatory detail on the
shell. I know that runs the executable, but please explain more about it.

Also, what is the syntax for the Username and password line? Finally, what
is the FtpComm.txt?
--
RMC,CPA


"Orlando Magalhães Filho" wrote in message
...
Hi Eric,

Try to use this code:

Public Sub FtpSend()
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long

vPath = ThisWorkbook.Path
vFile = "YourFile.csv"
vFTPServ = "ftp.yourserver.com"

'Mounting file command for ftp.exe
fNum = FreeFile()
Open vPath & "\FtpComm.txt" For Output As #fNum
Print #1, "user YourLogin YourPass" ' your login and password"
Print #1, "cd TargetDir" ' change to dir on server
Print #1, "bin" ' bin or ascii file type to send
Print #1, "put " & vPath & "\" & vFile & " " & vFile ' upload local
filename to server file
Print #1, "close" ' close connection
Print #1, "quit" ' Quit ftp program
Close

Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ,
vbNormalNoFocus
End Sub


HTH

---
Orlando Magalhães Filho

(So that you get best and rapid solution and all may benefit from the
discussion, please reply within the newsgroup, not in email)




"Eric" escreveu na mensagem
...
HI There,

Can anyone help me on how to use 'FTP' in vba macro. My
objective is, after converting my excel file to a CSV file
(comma delimited file) I want to FTP'd it to our
production server, using macro code.

I would appreciate very much your help.

Thanks
Eric