我有这样的代码:
Sub MoveFiles()
Dim d As String, ext, x
Dim srcPath As String, destPath As String, srcFile As String
srcPath = "C:\test\"
destPath = "C:\test2\"
ext = Array("*.csv", "*.xls")
For Each x In ext
d = Dir(srcPath & x)
Do While d <> ""
srcFile = srcPath & d
FileCopy srcFile, destPath & d
Kill srcFile
d = Dir
Loop
Next
End Sub但它会删除srcPath中的每个文件。我只需要它来删除activeworkbook.name,而不是每一个。我已经考虑了这段代码很长时间了,我想不出如何让它不循环,同时仍然做它应该做的事情。
我很感谢在这方面的一些帮助
发布于 2013-10-16 15:45:12
如果你只是想杀死一个特定的文件,那么为什么要使用一个循环来杀死迭代中的每个文件呢?
如果你想杀死一个特定的文件并且仍然循环,那么你需要添加一个" if“子句,如下所示:
if srcFile = activewindow.name then
kill
else
do nothing
end if还是我误会你了?
https://stackoverflow.com/questions/19397598
复制相似问题