Hi to all,
this macro delete files inside ThisWorkbook
this
TempFileName = "Selection of " & wb.Name & ".xlsx"
delete the file whitout minuts/second
this
TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") & ".xlsx"
not work
"Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") & ".xlsx" it's always different
you can change here to delete all files with the date
example
Selection of prova.xlsm 17-lug-22 17-12-03.xlsx
Selection of prova.xlsm 17-lug-22 17-32-21.xlsx
Selection of prova.xlsm 17-lug-22 17-42-33.xlsx
Selection of prova.xlsm 17-lug-22 17-52-53.xlsx
Sub delete_file_thunder_xlsx()
On Error Resume Next
Dim wk1 As Workbook
Dim miofile As String
Dim mioperc As String
Dim NomeXLSX As String
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Set wk1 = ThisWorkbook
Set wb = ActiveWorkbook
'il percorso
mioperc = wk1.Path & "\"
TempFilePath = mioperc
TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") & ".xlsx"
'TempFileName = "Selection of " & wb.Name & ".xlsx"
'NomeXLSX = mioperc & miofile
NomeXLSX = TempFilePath & TempFileName
Kill NomeXLSX
End Sub
I hope I have explained
thanks you
Bookmarks