Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am getting below error while calling Microsoft.Office.Interop.Word.Document Add method.

Office version is 2010

Error Details

Error Message : Word has encountered a problem.

Target Site   : Microsoft.Office.Interop.Word.Document Add(System.Object ByRef, System.Object ByRef, System.Object ByRef, System.Object ByRef)


Code:
C#
public MSWordMapping(string templateName, byte[] templateStream)
          : base(templateName, templateStream)
      {
          try
          {
              this.wordApp = new Microsoft.Office.Interop.Word.Application();
              this.wordDoc = this.wordApp.Documents.Add(templateName, false, Microsoft.Office.Interop.Word.WdNewDocumentType.wdNewBlankDocument, true);

              this.wordDoc.SaveAs(this.DocumentName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault);
              this.wordDoc.Close(true, Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat, Type.Missing);
              this.releaseObject(this.wordDoc);
              this.wordDoc = null;

              this.wordDoc = this.wordApp.Documents.Open(FileName: this.DocumentName);
              this.wordDoc.Activate();
          }
          catch
          {
              this.DeleteFile();
              throw;
          }
      }


This error getting only in one server all other server are working fine
Posted
Updated 4-Mar-14 0:02am
v3

i think its a assembly issue make sure that Microsoft.Office.Interop.Word is there at pariticular server

goto this path and check it out

C:\Windows\assembly
 
Share this answer
 
v2
Comments
Shanalal Kasim 4-Mar-14 6:13am    
Thanks for your reply. I check on that folder I found 'Microsoft.Office.Interop.Word'
Amalraj Ramesh 4-Mar-14 6:29am    
make sure that your web config that version no is same
Shanalal Kasim 4-Mar-14 6:38am    
In web.config there is no information add for Microsoft.Office.Interop.Word
Amalraj Ramesh 4-Mar-14 6:52am    
add like this

<add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C">
Shanalal Kasim 4-Mar-14 6:54am    
I think something is missing in your comment
Refer : http://www.4mghc.com/threads/129032-COMException-0x800A13E9-Word-interop-services[^]

Put a folder called Desktop on C:\Windows\SysWOW64\config\systemprofile (Yes I know. WTF?)
Open Regedit, Go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppId and edit the two enteries that have a Guid ending with 46. Delete every key they have and add a new key called RunAs with the value of Interactive User

After that, start praying.
It doesn't work if you access through a terminal server. Which is kind of a problem for me hehe.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900