+ Reply to Thread
Results 1 to 3 of 3

Corrupt file. Fail to open using the workbooks.open method

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Corrupt file. Fail to open using the workbooks.open method

    Hi everyone,

    I have a macro that open and close subsequently files. Sometimes these files are corrupted causing the method workbooks.open "NameOfMyFile.xlsx" to fail. (Run time error 1004, Method 'open' of object 'workbooks' failed)

    I have to open the file manually, it then says that "excel has found some unreadable content" and offer to correct the file. Once done and saved, I go back to my code and the file opens without any issue.

    My question: is there a method to force a corrupt file to open, correct it and save it, so that it can be opened by using the workbooks.open method?

    Thankfully

    Phil

  2. #2
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Corrupt file. Fail to open using the workbooks.open method

    Mortphi,

    It will be easy that copy data from corrupted file and paste it new file. Delete the corrupted file and rename new one.

    Regards,
    Nandkumar S.

  3. #3
    Registered User
    Join Date
    01-18-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Corrupt file. Fail to open using the workbooks.open method

    Thanks NandKumar S.

    I found a way to force a corrupt file to open. When using the workbooks.open method, there is an argument I did not know about called "corrupt load". So if one write worbooks.open Filename:= "TheNameofMyFile", CorruptLoad:= xlrepair , then the file opens. So I just made a loop opening all these files the one after the other and if they were corrupted I would save them using active workbooks.saveas and close it active workbook.close

    Phil

+ 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