Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a batch FTP via VBA - will not load or give errors

Status
Not open for further replies.

lobo3101

MIS
Aug 26, 2008
7
US
I'm trying to call a batch file that uses SFTP. If I double-click the batch file, it FTP's successfully. But when trying to call that .bat through VBA, I either receive strange errors or no error at all.

Method:
lShellResults = objShell.Run("R:\directory\SendSFTP.bat", 7, False)

Results:
"Automation error. No application is associated with the specified file for this operation.
-----------------------------------------------

Method:
shell "cmd /c R:\directory\SendSFTP.bat", vbNormalFocus

Results:
CMD window pops up and closes immediately. Goes to next line of code and does not upload file.
-----------------------------------------------

Again, the scripts sends successfully when double-clicking, but I cannot get it to work through VBA. Code compiles without issue so I'm fairly sure I've declared and set everything correctly.

Thoughts?
 
What about this ?
Code:
lShellResults = objShell.Run("""R:\directory\SendSFTP.bat""", 7, False)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That absolutely resolved it! Thank you so much.

If you have time, could you explain WHY that worked?
 
Seems like you have spaces in pathname.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top