Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

That command is wrong. I won't work anywhere. First test it on Windows command-line before trying it in VB.

Why cmd.exe? Remove it.
bbelote

Here is what I'm trying to run in VBA. This just leaves me with a blinking CMD prompt.

Sub CMDandSFTP()
 
Shell ("cmd.exe """C:\Program Files (x86)\WinSCP\WinSCP.com""" /ini=nul """/script=c:\Users\John Doe\Desktop\RCM1.txt""""), 1
 
End Sub
bbelote

The script runs if I delete the 'transfer binary' from my script.

My issue is still how do I call CMD in VBA.. and then paste the text for it to run? I start VBA and kick off the macro and I'm left with a blank CMD prompt
martin

Re: Failing Script

It looks good (except for binary/s).

What happens if you execute this on Windows command-line:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul "/script=c:\Users\John Doe\Desktop\RCGWM1.txt"
bbelote

Failing Script

I've devoured the forums and help topics and I'm still stuck.
Mostly I just end up pulling up the winscp.com prompt after all this. I have a million iterations of trying to get it to work. I'm trying to do this in VBA which is probably where I fall down. Goal is to SFTP a file everynight after a bunch of macros finish running in excel which is why I chose to house it in VBA.
First Iteration
Shell ("""C:\Program Files (x86)\WinSCP\WinSCP.com"" /ini=nul ""/script=c:\Users\John Doe\Desktop\RCGWM1.txt""")

This one doesn't even run the text file.
option batch abort
option confirm off
option transfer binary/s
 
open sftp://user:pass@xxxxxxxxxxx
 
lcd "C:\Users\John Doe\Dropbox\HF\Strat"
cd /UAT/TradeFile/test
 
put "FILL CSV"
Exit


Any help would be greatly appreciated. Like i said, most of my iterations just open up winscp.com command prompt and I can get it to logon but then they don't execute anything.