我需要在VBA中重命名一个文件,但是当它显然存在时会收到“找不到文件”

时间:2010-05-26 19:58:53

标签: file vba rename

帮助!尝试使用变量重命名文件时,我收到File Not Found错误。变量是string

我可以查看变量,它是那里的确切文件名,但是当我运行代码时,它说“找不到”!

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

1 个答案:

答案 0 :(得分:0)

我对VBA一无所知,但普通语言需要转义'\'。 所以试试“P:\\ Automated \\”等等。