ftp

B

Ben

Hi all -

I am trying to invoke FTP -s:filename.txt in my code, where the filename.txt
is in certain network mapped drive. Let's say it is at X:\Test\filename.txt


I tried the following lines but didn't quite work:

sub callFTP
Dim vTaskID As Variant

vTaskID = Shell("X:\Test\ftp -s:filename.txt", 0)
end sub

But it did not work. I want to know how I can invoke ftp and use the text
file in that directory. In addition, I wish to know if I must use a mapped
letter instead of the the UNC path.

Thanks,

Ben
 
B

Ben

Hi all,


I actually want to do something more specific:

vTaskID = Shell("X:\Test\ftp -s:filename.txt>log.txt", 0)

Thanks,

Ben
 
R

Rick Rothstein \(MVP - VB\)

Because you are doing redirection, you will need to specify the command
processor. Try it this way...

vTaskID = Shell(Environ$("comspec") & " /c
X:\Test\ftp -s:filename.txt>log.txt", 0)

although I think you may need to specify the path to filename.txt and
log.txt as well.

Rick
 
B

Ben

Rick,

It didn't quite work. Excel gave me an file not found error.

Thanks for your help.

Ben
 
R

Rick Rothstein \(MVP - VB\)

Do you in fact have an X: drive on your system and is there a sub-directory
on that drive named Test and within that directory is there a program named
ftp? Also, did you add paths to the filename.text file and the log.txt file
as I suggested? I also notice the newsreader broke the line I posted at a
required space... it is possible that you reconstructed the line without it.
Here is just the part that goes after the equal sign (it should be short
enough not to get broken)...

Shell(Environ$("comspec") & " /c X:\Test\ftp -s:filename.txt>log.txt", 0)

Copy/Paste it over top of whatever you have after the equal sign in the
original code line I posted.

I can tell you for sure, the Environ("comspec") part I gave you is NOT the
cause of your error. You can prove that to yourself by executing this
statement in the Immediate window...

? Environ("comspec")

It will probably print out "C:\Windows\system32\cmd.exe" (without the quote
marks). The <space>/c<space> that I added in front of the X:\Test\ftp text
from your original posting tells the command processor to close itself after
it is done (if you wanted to leave the command processor window up, you
would replace the /c with /k instead).

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top