0
我希望你能在這裏幫我一些代碼。我創建了一個模塊來創建一個ftp命令文件,然後創建一個批處理文件來執行它。Excel vba ftp成功但服務器上沒有文檔?
我得到這個過程從另一個StackOverflow上一篇: FTP a text file to a server using VBA in Excel
一些時間test.txt的顯示出來的服務器,大部分時間它沒有。但是,ftp提示始終報告成功傳輸。
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
感謝