Sub Button1_Click()
Dim a
ipaddress = ActiveSheet.Cells(3, 2).Value
UserName = ActiveSheet.Cells(4, 2).Value
Password = ActiveSheet.Cells(5, 2).Value
Path = ActiveSheet.Cells(6, 2).Value
a = ActiveSheet.Cells(7, 2).Value 'Reports needs to be downloaded
aSplit = Split(a, ",")
Const ForWriting = 2
Dim objOutStream, objjFSO, objShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutStream = objFSO.OpenTextFile("C:\Documents and Settings\FTPCommand.txt", ForWriting, True)
With objOutStream
.WriteLine UserName
.WriteLine Password
.WriteLine "binary"
.WriteLine Path
For i = 0 To UBound(aSplit)
aSplit(i) = Trim(aSplit(i))
.WriteLine "get ES." & aSplit(i)
Next
.WriteLine "quit"
.Close
End With
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k FTP -n -i -s:" & "C:\Documents and Settings\FTPCommand.txt" & " " & ipaddress, 1, True
End Sub
运行宏代码后的文本文件:
Username
Password
binary
Path
get ES.1312
get ES.3243
get ES.4534
quit
文本文件中的命令不执行。我不知道如何解决它。
请帮助...提前感谢您的帮助。