我正在使用以下代码尝试创建.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"