guice99
guice99

Reputation: 55

Sync local and remote file using VBA and WinSCP

I'm trying to auto sync local files with a server using WinSCP. I'm getting the following script error:

enter image description here

Here is my vba code:

Public Sub pullwinscp()
Shell "wscript C:\Users\Aaron\Desktop\SyncSftp.vbs", vbNormalFocus
End Sub

And here is the script I'm trying to call (saved as .vbs):

open sftp://User:[email protected] -hostkey="aaaaa-aaa2 aaaaa256 7a:4a:aa:aa:aa:aa:aa:aa:a1:aa:aa:aa:aa:aa:aa:aa"
synchronize local C:\Users\Aaron\Documents\test /home/FTP/Acct Hourly Acctg

Any ideas why I'm getting this error?

Upvotes: 2

Views: 800

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202088

Your ".vbs" is not VBScript code. That's WinSCP script.

To run WinSCP script from VBA, use:

Call Shell("C:\path\winscp.com /ini=nul /script=c:\path\SyncSftp.txt")

(after you rename SyncSftp.vbs to SyncSftp.txt, as it's not VBScript)

See also Using VBA to run WinSCP script.

Upvotes: 1

Related Questions