I am using Microsoft Office 2010 PIA to convert word and excel documents to PDF. I faced corrupted files. In Excel we can repair, then open corrupted files:
Missing missing = Missing.Value;
Application excel = new Application();
Workbook workbook = excel.Workbooks.Open(sourceFilePath,
missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing,
missing, missing, missing, XlCorruptLoad.xlRepairFile);
The standard Open
method has an OpenAndRepair
parameter which you can set to True to repair the document, if necessary, when opening it.
Word also has the method Documents.OpenNoRepairDialog
which you could use instead of the standard Documents.Open
in order to suppress the user prompt.
Note: Whether either of these is actually able to repair the document will depend on what kind of damage is present. Also, you need to be aware that some repairs will actually change the content (remove damaged things, for example), so that the document can be opened.