Tag: winscp

使用Excel从FTP客户端上传和下载文件

我无法获得下面的代码工作(从这里的答案在VBA中使用FTP )。 我是从WinSCP的FTP客户端,我不是100%确定如何使用代码。 当我运行macros,我得到了成功的MsgBox“发送”popup窗口,我看到一个名为FTP_BATCH_FILE_NAME的文件被创build并保存了以下信息: "open " & FTP_ADDRESS FTP_USERID FTP_PASSWORD "mput " & sWorkingDirectory & sFileToSend quit 发布代码的人注意到 – “单步执行代码时,可以在即时窗口中键入以下命令,然后将结果复制/粘贴到命令窗口中:” ? Shell "ftp -i -w:20480 -s:" & sWorkingDirectory & FTP_BATCH_FILE_NAME 但是,当我执行代码时,在黄色突出显示在Excel中通过此行后,我input此行,并且出现“?”,sWorkingDirectory和FTP_BATCH_FILE_NAME未被识别为内部或外部命令的错误。 我以为,在Cmd行input后,我可以将FTP_BATCH_FILE_NAME的内容放到sFileToSend中,但是没有任何东西放到sFileToSend中。 Option Explicit Const FTP_ADDRESS = myHostAddr Const FTP_USERID = myUsername Const FTP_PASSWORD = myPassword Sub Macro1() If Not SendFtpFile_F() Then MsgBox "Could not […]

Visual Basicstring语法错误,同时尝试自动化WinSCP

我希望使用东西string使用Shell()函数来自动上传一个Excel文件到FTP服务器,每当一个保存发生时: strShell = "C:\Program Files\WinSCP\WinSCP.exe /console /command " & Chr(34) & "option batch on" & Chr(34) & " " & Chr(34) & "open user:pass@localhost" & Chr(34) & " " & Chr(34) "put " ThisWorkbook.Path & "/" & ThisWorkbook.Name & "/home/User/Directory" & Chr(34) & " " & Chr(34) "exit" & Chr(34) 出于某种原因,我得到这个string的语法错误。 我在VBA方面的知识并不广泛,但是在过去的几个小时里,我经历了MSDN,似乎没有任何帮助。

使用VBA运行WinSCP脚本

我能够通过使用以下代码在CMD窗口中从SFTP下载文件: WinSCP.com # Connect to the host and login using password open user:pw@address # get all the files in the remote directory and download them to a specific local directory lcd C:\Users\xx\Desktop get *.xlsx # Close and terminate the session exit 我在网上search,发现我可以把这些代码放在bat文件中并使用 Call Shell("cmd.exe /c C:\Users\xx\Desktop\WinSCPGet.bat", 1) 但是,只有bat文件的第一行WinSCP.com正在执行。 它会popupcmd窗口,显示这个,没有做任何事情。 如何一次执行所有的行? 谢谢