Getting an Exception : (HRESULT: 0x800A140C ) while trying to close Word 2k10 Document
-
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a
-
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a
Googling your error code gives remarkably few hits, the most promising one is http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/Q_26382757.html[^] which needs you to create a temporary account in order to read the "accepted solution". Not sure it will be any good though. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a
Hello Kushagra, what is the value ofthe variable mArg. It's being used in some places where a boolean is expected, but also as the last parameter where no boolean is expected. Parameter 11 has to do with encoding (as far as the comments go at least) but it's passed a boolean (fArg). Are your sure all the parameters are of the proper type and have a meaningfull value? Supplying a wrong parameter might still allow opening the document, but a subsequent save could fail. Best Regards, Manfred
-
Hello Kushagra, what is the value ofthe variable mArg. It's being used in some places where a boolean is expected, but also as the last parameter where no boolean is expected. Parameter 11 has to do with encoding (as far as the comments go at least) but it's passed a boolean (fArg). Are your sure all the parameters are of the proper type and have a meaningfull value? Supplying a wrong parameter might still allow opening the document, but a subsequent save could fail. Best Regards, Manfred
ManfredRBihy wrote:
what is the value ofthe variable mArg. It's being used in some places where a boolean is expected, but also as the last parameter where no boolean is expected.
mArg is nothing but NULL which specifies missing value to let the function decide its own default value. I will look for replacing the right parameters .. meanwhile if you find some good solution on this .. please let me know. -Kushagra
-
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a
I haven't worked with the Word Interop, but I've done quite a bit with Excel Interop, which I would guess is similar... Instead of using dummy variables for parameters you don't want, use "Type.Missing" instead. For example, here's a line from one of my production systems that saves a file in Excel:
Ref.SaveAs(outputFile, -4143, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);"Ref" points to a Microsoft.Office.Interop.Excel.Workbook, outputFile is just a plain string variable. You shouldn't need to use dummy variables and "ref" keywords for everything.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a
I finally got this sorted ... Looks there is some issue with Save() api of WOrd 2010 where its not able to decide which format to save the document in ... I used SaveAs() instead and then closed the Document... which worked wonders in my case.. -Kushagra
-
I finally got this sorted ... Looks there is some issue with Save() api of WOrd 2010 where its not able to decide which format to save the document in ... I used SaveAs() instead and then closed the Document... which worked wonders in my case.. -Kushagra
Apparently this issue occurs because the Compatibility Mode feature in Office 2010 (Word, Excel, etc.) has been turned off. I guess there are two ways you can fix this. Turn the Compatibility Mode feature back on or like the previous post mentions use the SaveAs() method instead. Using the SaveAs() method fixed the issue for me: Microsoft.Office.Interop.Word._Document msWord = new Document(); object filename = "C:\\SomeWordFile.doc"; // Open the document. Perform operations on the msWord object. // ... // ... // When it comes to close the document do something like this: object fileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument; object missing = System.Reflection.Missing.Value; object notTrue = false; msWord.SaveAs(ref filename, ref fileFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); msWord.Close(ref notTrue, ref missing, ref missing); Hope this helps.
-
Hi all, I have tried to open an existing Word 2k10 document in mail merge format.
private object tArg = true;
private object fArg = false;
private object wOriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;sourceDoc = word.Documents.Open(ref oSourceFile,//1The name of the document (paths are accepted).
ref mArg,//2True to display the Convert File dialog box if the file isn't in Microsoft Word format.
ref mArg,//3True to open the document as read-only.
ref mArg,//4True to add the file name to the list of recently used files at the bottom of the File menu.
ref mArg,//5The password for opening the document.
ref mArg,//6The password for opening the template.
ref mArg,//7Controls what happens if FileName is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document.
ref mArg,//8The password for saving changes to the document.
ref mArg,//9The password for saving changes to the template.
ref wdOpenFormatAllWord,//10The file converter to be used to open the document. Can be one of the following WdOpenFormat constants
ref fArg,//11The document encoding (code page or character set) to be used by Microsoft Word when you view the saved document.
ref mArg,//12True if the document is opened in a visible window. The default value is True.
ref mArg,//13Specifies whether to open the conflict file for a document with an offline conflict.
ref mArg,//14True to repair the document to prevent document corruption.
ref mArg,//15True to skip displaying the Encoding dialog box that Word displays if the text encoding cannot be recognized. The default value is False.
ref mArg);//16Indicates the horizontal flow of text in a document. The default value is wdLeftToRight.a