+ Reply to Thread
Results 1 to 2 of 2

Kill command stops on missing file

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    22

    Kill command stops on missing file

    I came back to work this morning after a two-day vacation. While I was gone, I received a new laptop with my files moved back over without my backed up macros. I now have to rebuild my macros.

    I am using the Kill command to remove my source data files at the end of my macro before using application.quit.

    Kill "C:\users\name\Desktop\folder\file1.csv"
    Kill "C:\users\name\Desktop\folder\file2.csv"
    Kill "C:\users\name\Desktop\folder\file3.csv"
    Kill "C:\users\name\Desktop\folder\file4.csv"
    Application.Quit
    End Sub

    Not all the files will have data in them (the file is not brought over), so if file3.csv is not present the debugger comes and doesn't bypass it and delete file.4csv. How dow I get kill to ignore file3.csv if it is not present? I had this working before my computer refresh.

    Any help would be appreciated.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Kill command stops on missing file

    Check if the file exists using Dir before trying to delete it.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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