此宏返回一个53错误。
如果我将CSVPath2变量与Kill命令一起使用,宏会起作用,但如果我使用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
您需要完整的filespec(包括路径)
在我的机器上:
Sub DELETE()
Dim CSVPath As String
Dim sProcessFile As String
CSVPath = "C:TestFolder"
sProcessFile = Dir(CSVPath & "*.csv")
Kill CSVPath & sProcessFile
End Sub