用双引号将完整的文件path包裹起来
我有一个文件,我需要使用VBA的FTP,我已经想通了,除了最后一个,我需要插入"
在文件名称,但无法做到。
csvPath = "C:\Users\10613527\Desktop\test\" sWorkingDirectory = csvPath sFileToSend = "Price_Change_10-08-15 20-35-49.csv" iFreeFile = FreeFile Open sWorkingDirectory & FTP_BATCH_FILE_NAME For Output As #iFreeFile Print #iFreeFile, "open " & FTP_ADDRESS Print #iFreeFile, FTP_USERID Print #iFreeFile, FTP_PASSWORD Print #iFreeFile, "ASCII" Print #iFreeFile, "put " & sWorkingDirectory & sFileToSend Print #iFreeFile, "dir" Close #iFreeFile 'Shell command the FTP file to the server Shell "ftp -i -w:20480 -s:" & sWorkingDirectory & FTP_BATCH_FILE_NAME
在上面的代码中,我得到该文件没有find的错误。
原因是文件path和名称不在""
,例如这段代码正在编写另一个脚本文件并执行该文件。
所以它需要
open ftp path username password ASCII put "C:\Users\10613527\Desktop\test\Price_Change_10-08-15 20-35-49.csv" dir
并不是
open ftp path username password ASCII put C:\Users\10613527\Desktop\test\Price_Change_10-08-15 20-35-49.csv dir
注意PUT语句中的" "
,我不知道如何把它们放在那里。
在vbstring中使用""
来转义。
所以
Print #iFreeFile, "put """ & sWorkingDirectory & sFileToSend & """"