Word在调用Microsoft.Office.Interop.Word.Document Add时遇到问题 [英] Word has encountered a problem while calling Microsoft.Office.Interop.Word.Document Add

查看:443
本文介绍了Word在调用Microsoft.Office.Interop.Word.Document Add时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在调用Microsoft.Office.Interop.Word.Document添加方法时遇到错误。



Office版本是2010



错误详细信息



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:

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

推荐答案

我认为它的装配问题确保Microsoft.Office.Interop.Word在pariticular服务器上



转到此路径并查看



C:\ Windows \assembly
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


参考: http://www.4mghc.com/threads/129032-COMException-0x800A13E9-Word-interop-服务 [ ^ ]



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.


这篇关于Word在调用Microsoft.Office.Interop.Word.Document Add时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆