我需要在 VBA 中重命名文件,但得到“文件未找到”当它明显存在时
帮助!尝试使用变量重命名文件时,出现File Not Found
错误。该变量是一个字符串
。
我可以查看该变量,它是那里的确切文件名,但是当我运行代码时,它显示“未找到”!
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
Help! I'm getting a File Not Found
error when trying to rename a file with a variable. The variable is a string
.
I can look at the variable and it's the exact filename that is there, but when I run the code, it says "not found"!
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对VBA一无所知,但普通语言需要转义“\”。
所以尝试“P:\\Automated\\”等。
I don't know anything about VBA, but normal languages require a '\' to be escaped.
So try "P:\\Automated\\" etc.