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
テキストファイル内のコマンドは実行されません。修正方法がわかりません。
助けてください...事前に助けてくれてありがとう。