[英]Excel macro overwrite existing file
I am trying to move many Excel files using a wildcard from \\Output
folder to \\Output\\Archive
folder. 我正在尝试使用通配符将许多Excel文件从\\Output
文件夹移至\\Output\\Archive
文件夹。 If a file is already present in the Archive folder, it should be overwritten. 如果存档文件夹中已经存在文件,则应将其覆盖。
This is my code (also shown in the attached image) 这是我的代码(也显示在附图中)
Application.DisplayAlerts = False
Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
FSO.MoveFile Source:=Excel_Path & Excel_Name, Destination:=Excel_Path & "Archive\" & Excel_Name
Application.DisplayAlerts = True
It is still throwing an error 它仍然抛出错误
File already exists 文件已存在
Almost everyone suggests to disable the display alert but in my case it is not working. 几乎每个人都建议禁用显示警报,但就我而言,它不起作用。
Am I missing anything here? 我在这里想念什么吗? Can someone help? 有人可以帮忙吗?
TIA, Sanket K. TIA,Sanket K.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.