View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default FTP using CMD via VBA

sachin ahuja wrote:

I am using below code for FTP using vbscript.

Please help me to do same task via VBA.


It depends on what you actually want to do. If you want to specifically
automate ftp, the best way is to use what amounts to a batch file:

'Untested air code...
bakdir$ = CurDir$
ChDir "\"
ftpf = FreeFile
Open "ftpcmds.tmp" For Output As ftpf
Print #ftpf, "open mvsftp"
Print #ftpf, usrID & "
'No need to explicitly wait; ftp will worry about such things for you.
Print #ftpf, Password
Print #ftpf, "get"
Print #ftpf, "'" & dataset & "'"
Print #ftpf, filePath
'At this point, you may want to add an explicit exit to the batch:
'Print #ftpf, "bye"
Close ftpf&
Shell "ftp -s:ftpcmds.tmp"
ChDir bakdir$

If you just need to grab files from an ftp server, you should be able to
connect to it via code and grab your files directly. I'm sure there are
plenty of examples for doing that on the www; Google is your friend.

--
You can't turn the volume down on beating a hooker with a baseball bat.