PDA

View Full Version : VBA - open corrupted file - excel 2010



Yan_A
02-26-2018, 03:22 AM
Hello,
I have some files that when I manually try to open them come up with the below message:
Excel found unreadable content in "***.xlsx". Do you want to recover the contnents of the workbook? .....
When I click YES it shows me the below:
Excel was able to open the file by repairing or removing the unreadable content.
Removed Feature: Data validation from /xl/worksheets/sheet1.xml part
And then I can manually save it, replace it, and the file thereafter opens normally with no errors.
Now my problem is... I want to do the same with a VBA code...
I prepared the below and there is no luck... It comes with 1004 error:





Sub letshope()


WithApplication
.DisplayAlerts=False
.ScreenUpdating=False
.EnableEvents=False
.AskToUpdateLinks=False
EndWith

Set wb =Workbooks.Open(Filename:= _
"\\folder\***.xlsx", _
UpdateLinks:=0,Password:="password", _
IgnoreReadOnlyRecommended:=True, _
CorruptLoad:=XlCorruptLoad.xlRepairFile)


EndSub


Unfortunately everybody on the web suggests that with the "CorruptLoad:=XlCorruptLoad.xlRepairFile" part all corrupted files open...
This is not the case...
Anyone who might have any kind of idea please?
It is a painful process opening them manually, saving them etc....



Once I manually open them and press to recover they all come up with the same error:


error067760_07.xml





Errors were detected in file '******.xlsx'</summary>
-<removedFeatures summary="Following is a list of removed features:">
<removedFeature>Removed Feature: Data validation from /xl/worksheets/sheet1.xml part</removedFeature></removedFeatures></recoveryLog>



Thanks!!!

werafa
02-26-2018, 09:17 PM
I struck something similar once - and it appeared to be a bug to do with the data validation.
is the validation set manually or via vba?

it would work, the workbook would save correctly, and would always open with the 'errors were detected' message.
I was never able to beat it, and had to find a different way to achieve what I needed.

if this is what it is, it is an obscure error, but the right search words in google will show a few hits for you.