Sunny Gakhar


I am receiving following error while opening word template programatically:

System.Runtime.InteropServices.COMException (0x800A141F): Word was unable to read this document. It may be corrupt.
Try one or more of the following:
* Open and Repair the file.
* Open the file with the Text Recovery converter.

at Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible)

I am using the following code to add the template:

Word.Application wrdApp = new Word.Application();
Word._Document wrdDoc;
Object oMissing = System.Reflection.Missing.Value;
Object oTemplate = null;

wrdApp.Visible = false;

string TemplateFileName = null;
oTemplate = "";

TemplateFileName = GetTemplateFileName(templateID);

if (TemplateFileName == string.Empty)
throw new Exception("Template not found.");

// assign to the object
oTemplate = TemplateFileName;
// Add a new document.
wrdDoc = wrdApp.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);

Please note that I am using reference to Word.dll with version in my project and I am not able to reproduce this error on consistent basis.

Please provide help in resolving this issue.



Re: Visual Studio Tools for Office Receiving COMException (0x800A141F) while opening word template programatically

Cindy Meister

Hi Sunny

This forum is specifically for questions regarding the VSTO addon for Visual Studio. It's not for general Office application support, and the limited object model support done here is for Office 2003 (11.0) and later.

The version of Word you're trying to automate is 97, quite an old version. The best place for you to get assistance with automating any Office application is either an application-specific newsgroup, or an Office developer newsgroup. You'll find these listed in the "Please Read First" message at the top of this forum.

right off-hand, though, I'd say you should take a close look at the Documents.Add method signature in the Word 97 VBA Help. As I recall, it didn't have four parameters...

Re: Visual Studio Tools for Office Receiving COMException (0x800A141F) while opening word template programatically

Sunny Gakhar

Hi Cindy,

Thanks for the redirection.