我是Excel VBA的初学者和新手,但我试图通过连接到Excel并可能创建一个有用的宏来自动化FTP(WinSCP)中的一些文件共享。 在FTP中我去了Session> Generate Session URL / code> Script(脚本文件),下面是代码:
open ftp://myUsername:myPassword@theHostname/
# Your command 1
# Your command 2
exit
open ftp://myUsername:myPassword@theHostname/
Option Explicit
Sub FtpTest()
MsgBox fnDownloadFile("ftp://yoursite", "username", "password", _
"The name of your file", _
"C:\The name of your file to save as")
End Sub
Function fnDownloadFile(ByVal strHostName As String, _
ByVal strUserName As String, _
ByVal strPassWord As String, _
ByVal strRemoteFileName As String, _
ByVal strLocalFileName As String) As String
'// Set a reference to: Microsoft Internet Transfer Control
'// This is the Msinet.ocx