2010-05-26 25 views
0

幫助!嘗試使用變量重命名文件時,出現File Not Found錯誤。該變量是一個string我需要在VBA中重命名一個文件,但是當它清晰時出現「文件未找到」

我可以看看變量,它是那裏的確切文件名,但是當我運行代碼時,它說「找不到」!

Dim filePath, fileName, absPath, newPath As String 
filePath = "P:\Automated\" 
fileName = MySite.GetResult 
absPath = filePath & fileName 
newPath = "P:\Automated\NEW.csv" 

'The following is a rename from CuteFTP Pro COM Object: 
'(Getting the same result from this and the below "Name". 
'MySite.LocalRename "P:\Automated\" & fileName, "P:\Automated\NEW.csv" 

Name absPath As newPath 
+0

名稱中是否有空格?你用filesystemobject得到什麼? – Fionnuala 2010-05-26 20:12:11

+1

你有權限嗎?錯誤消息有時不太可靠。 – 2010-05-26 20:12:19

回答

0

我對VBA一無所知,但普通語言需要'\'才能被轉義。 因此請嘗試「P:\\ Automated \\」等。

+1

「正常」? Delphi是很正常的。你可能是指「多種語言」或「某些語言」? – 2010-05-26 20:10:53

+1

VBA的情況並非如此,VBA仍然適度。 – Fionnuala 2010-05-26 20:12:47

相關問題