0

ここでいくつかのコードを手伝ってくれることを願っています。ftp コマンド ファイルを作成し、それを実行するためのバッチ ファイルを作成するモジュールを作成しました。

このプロセスは、別の StackOverflow の投稿から取得しました: FTP a text file to server using VBA in Excel

test.txt がサーバーに表示される場合もありますが、ほとんどの場合は表示されません。ただし、ftp プロンプトは常に転送の成功を報告します。

ftp.exe のスクリーンショットが正常に転送されました。

Private Sub SendFileToServer()
Dim sCmdFile As String
Dim sBatFile As String
Dim vPath As String
Dim iFileNum As Integer

vPath = ThisWorkbook.Path
sCmdFile = vPath & "\" & "ftp" & "\" & "ftpCommand.txt"
iFileNum = FreeFile

  Open sCmdFile For Output As iFileNum
    Print #iFileNum, "open 555.555.555.55"
    Print #iFileNum, "user username"
    Print #iFileNum, "password"
    Print #iFileNum, "hash"
    Print #iFileNum, "ascii"
    Print #iFileNum, "lcd " & vPath
    Print #iFileNum, "cd dsi_Timesheets"
    Print #iFileNum, "put " & vPath & "\" & "test.txt"
    Print #1, "close"
    Print #1, "quit"
  Close #iFileNum

    Shell "ftp -n -i -g -s:" & vPath & "\ftp" & "\ftpCommand.txt " & vFTPServ,    vbNormalNoFocus
    SetAttr vPath & "\ftp" & "\ftpCommand.txt", vbNormal
    Kill vPath & "\ftp" & "\ftpCommand.txt"
End Sub

ありがとう

4

1 に答える 1