此宏返回53错误。
如果我使用带有Kill命令的CSVPath2变量,宏可以工作,但是如果我使用sProcessFile变量则不行。
Sub DELETE()
Dim CSVPath As String
Dim CSVPath2 As String
Dim sProcessFile As String
CSVPath = "c:\TEST\"
'CSVPath2 = "c:\TEST\*.csv"
sProcessFile = Dir(CSVPath & "*.csv")
Kill sProcessFile
End Sub
答案 0 :(得分:1)
您需要完整的文件规范(包括路径)
在我的机器上:
Sub DELETE()
Dim CSVPath As String
Dim sProcessFile As String
CSVPath = "C:\TestFolder\"
sProcessFile = Dir(CSVPath & "*.csv")
Kill CSVPath & sProcessFile
End Sub