+ Reply to Thread
Results 1 to 3 of 3

VBA Script to delete files gets error '53' when it finds a corrupt file

  1. #1
    Registered User
    Join Date
    08-18-2013
    Location
    Baltimore, Maryland
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    4

    VBA Script to delete files gets error '53' when it finds a corrupt file

    Hello,

    I am in the process of deleting about 10,000 files from a shared network drive. I've identified the files to be deleted on a spreadsheet and the script runs, but sometimes stops with an "run time error 35 - file cannot be found. This has happened with about 10 files out of 4000, but one bad file stops the script every time.

    I've noticed that the files that top the script show that there is an actual file with KBs of storage, but they will not open. I cannot open the file if I navigate to it and try to open it. Word docs start to open then Word shuts down and the PDF files that stop the script don't open either. They try to open then I get an access denied error. Some of these files have been moved so much and the libraries so poorly organized, perhaps a few files have gotten corrupt. I'm trying to delete about 200 files at at time and if I get an error in that range and keep narrowing it down until I find the file(s) that is holding it up.

    Is it possible to have it continue past files that the script sees an error with??
    I have attached a copy of the macro with the debug error highlighted in yellow. Thank you for taking a look!
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: VBA Script to delete files gets error '53' when it finds a corrupt file

    This will tell the script to go to the next line when an error occurs:
    Please Login or Register  to view this content.
    Last edited by carlmon; 05-12-2022 at 02:49 PM.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Script to delete files gets error '53' when it finds a corrupt file

    How about adding some error handling or in this case ignoring but checking after ...?

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Corrupt File Error traced to Advanced Filter
    By SKKS in forum Excel General
    Replies: 0
    Last Post: 03-18-2021, 01:59 PM
  2. [SOLVED] Script Help - Compare Cell Value against File Name for Multiple Files into one XL
    By gaz_0001 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-02-2019, 08:22 AM
  3. What's the VBA script to delete file from Excel
    By EvelynLoh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-28-2017, 09:30 AM
  4. How to add a line of VBA script to delete file?
    By EvelynLoh in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 12-25-2017, 08:31 PM
  5. Replies: 4
    Last Post: 10-17-2014, 09:31 AM
  6. VBA script to compare latest two files and get output to another file
    By arkrish in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2013, 01:17 PM
  7. Replies: 6
    Last Post: 01-17-2006, 08:45 AM

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