Sub 删除文件()
Dim myFile As String
myFile = ThisWorkbook.Path & "\VBA基实很简单.xlsm"
On Error Resume Next
Kill myFile
On Error GoTo 0
End Sub
Sub 删除文件()
Dim myFile As String
Dim myNewFilePath As String
Dim fso As Scripting.FileSystemObject
myFile = ThisWorkbook.Path & "\VBA基实很简单.xlsm" '要删除的文件
Set fso = New Scripting.FileSystemObject
If fso.FileExists(myFile) Then
fso.DeleteFile myFile
MsgBox "已经将文件 " & myFile & " 删除"
Else
MsgBox "要删除的文件不存在"
End If
Set fso = Nothing
End Sub