我需要在 VBA 中重命名文件,但得到“文件未找到”当它明显存在时

发布于 2024-09-02 17:30:02 字数 541 浏览 1 评论 0原文

帮助!尝试使用变量重命名文件时,出现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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

緦唸λ蓇 2024-09-09 17:30:02

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

I don't know anything about VBA, but normal languages require a '\' to be escaped.
So try "P:\\Automated\\" etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文