私は自分のコードをこのように書いています。
function ftpsend()
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long
Dim currntdir As String
currntdir = ThisWorkbook.Path & "\"
vPath = currntdir
vFile = currntdir & "abc.xml"
vFTPServ = "ftp.abc.com"
'Mounting file command for ftp.exe
fNum = FreeFile()
Open vPath & "abc.txt" For Output As #fNum
Print #1, "USER student"
Print #1, "xxxxx"
Print #1, "send " & vFile
Print #1, "close"
Print #1, "quit"
Close
Shell "ftp -n -i -g -s:" & vPath & "abc.txt " & vFTPServ, vbNormalFocus
end function
これで、シェル コマンドはコンソール ftp.exe に出力を次のように表示します。
Connected to ftp.abc.com
220 Microsoft FTP service
ftp>USER student
230 User logged in
ftp>send D:abc.xml
200 PORT command successful
226 Transfer Complete
ftp>close
221>Good bye
ftp>
この出力をコンソールからテキスト ファイルにコピーしたいのですが、ユーザー名とパスワードが間違っていると、コンソールに「ユーザーがログインしていません」、「ログインに失敗しました」というメッセージが表示されることがあるため、処理したいそのエラー。ftp エラーを処理する他の方法はありますか? 助けてください...
前もって感謝します