我正在使用以下代碼嘗試創建.txt文件並將其上傳到我的FTP服務器。我想創建一個名爲Ref.txt
的文本文件,並在文本文件中插入一些單元格值,然後將其上傳到我的FTP服務器。出於某種原因,我沒有得到任何錯誤,但文本文件沒有上傳到我的FTP服務器。創建文本文件,在文本文件中打印單元格值並上傳到FTP服務器?
有人能告訴我我要去哪裏嗎?
我想在用戶P:/
驅動器上創建一個名爲Ref.txt
的臨時文本文件,然後打印irange("A1").value
。
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long
vPath = "P:\"
vFile = Ref & ".txt"
vFTPServ = "********"
'Mounting file command for ftp.exe
fNum = FreeFile()
Open "P:\" & Ref & ".txt" For Output As #fNum
Print #1, "hewdenportal.co.uk" ' your login and password"
Print #1, "/public_html/ns_requests" 'change to dir on server
Print #1, "bin" ' bin or ascii file type to send
Print #1, "put " & vPath & "\" & vFile & " " & vFile ' upload local filename to server file
Print #1, "close" ' close connection
Print #1, "quit" ' Quit ftp program
Close
Shell "ftp -n -i -g -s:" & vPath & Ref & ".txt" & vFTPServ, vbNormalNoFocus
SetAttr vPath & Ref & ".txt", vbNormal
Kill vPath & Ref & ".txt"