谁能告诉我一种使用 vba 将文件从一个文件夹复制到另一个文件夹的方法,但条件是如果文件已经存在则不覆盖?
这是我的代码:
If Target.Column = Range("BL1").Column And Target.Row > 14 Then
FileCopy "\\UKSH000-FILE06\purchasing\New_Supplier_Set_Ups_&_Audits\assets\audit.xls", "\\UKSH000-FILE06\purchasing\New_Supplier_Set_Ups_&_Audits\ATTACHMENTS\" & Range("B" & ActiveCell.Row) & "\audit.xls"
End If
最佳答案
为了清晰起见,稍微简化您的路径:
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists("\\path\to\destination" & stuff & "\audit.xls") Then
FileCopy "\\path\to\source\audit.xls", "\\path\to\destination\" & stuff & "\audit.xls"
End If
关于excel vba - 将文件从一个文件夹复制到另一个文件夹但如果文件存在不覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26033696/