Working with Office 2010, I'm able to access to .docx file without problem, using DocumentFormat.OpenXml.
But, for .doc, it fails (the files have old winword format).
Microsoft.Office.Interop.Word.Application wordApp;
wordApp = new Microsoft.Office.Interop.Word.Application();
Object oFileName = fullFilePath;
object missing = System.Reflection.Missing.Value;
object oFormat = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatDocument97;
object saveChange = false;
try {
Microsoft.Office.Interop.Word.Document doc =
_wordApp.Documents.Open( ref oFileName, ref missing , ref missing ,
ref missing , ref missing , ref missing , ref missing ,
ref missing , ref missing , ref oFormat, ref missing ,
ref isVisible, ref missing , ref missing , ref missing , ref missing );
textBuilder.Append( doc.Content.Text );
wordApp.Documents.Close( ref saveChange, ref missing, ref missing );
}
catch (Exception ex) {
textBuilder.Append( "<ERROR>" + "\n" + ex.Message );
}
finally {
wordApp.Quit(ref saveChange, ref missing, ref missing );
wordApp = null;
}
With all possibles values of 'WdOpenFormat', I got always exception (fictive "concurent access").
How to solve that ?
Best regards.