Is there VBA code that can delete Excel files?
Any help or example would be welcome.
Here is something I use. Very clean and effective:
Sub DeleteTEMPIMPORTWorkbook()
Dim MyDir As String, fn As String
MyDir = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & "\My Files" ' Change this to the directory where the file you need to delete is located.
On Error Resume Next
Kill MyDir & "\TEMPIMPORT.xlsx"
On Error GoTo 0
End Sub
Please note, using Kill does NOT send the file to the Recycle Bin. It will permanently delete the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With