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
感谢