Results 1 to 3 of 3

vba kill file

Threaded View

john_cash vba kill file 07-17-2022, 11:55 AM
john_cash Re: vba kill file 07-17-2022, 03:36 PM
john_cash Re: vba kill file 07-17-2022, 04:03 PM
  1. #1
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    vba kill file

    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
    Last edited by john_cash; 07-17-2022 at 02:49 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Save zip file from web Open CSV inside WinZip WinRar file and later kill zip or rar
    By analystbank in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2021, 05:41 AM
  2. [SOLVED] Kill file bloat
    By BRISBANEBOB in forum Excel General
    Replies: 4
    Last Post: 06-08-2016, 07:06 PM
  3. Can't Kill file - Permission Denied
    By simonc2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2013, 11:13 AM
  4. [SOLVED] Save as then Kill old file
    By amoxia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2013, 11:48 PM
  5. Kill Command Crashes if File is Not There
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2012, 06:10 PM
  6. [SOLVED] Kill file
    By EW in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-16-2006, 10:35 PM
  7. Kill a File
    By Posse John in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2006, 09:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1