Interop.Word Documents.Open stuck

99封情书 提交于 2019-12-24 00:53:59

问题


I have same application on two different machine. On first machine all work fine, while in second machine I have a problem.

Debugging code I can see that when Interop.Word Documents.Open is called then execution remains locked, and never go to next code line, while browser (IE7) stuck on loading.

I need to open a word template, write in opened document, and then close it. So I do following :

_Application wdApp = new Application();
wdApp.Documents.Open(templatePath);

Why on first machine this works? There are reference problems ? I add same Interop dll in my machine...

In DCOM Config Settings I have same configuration on the two machine for Microsoft Word 97-2003 Documents:

identity -> Launching User

protection -> ASPNET user and ADMINISTRATOR with all permission

  • 1 - edit : the page is locked, in debugging when I go to :

    wdApp.Documents.Open(templatePath);

nothing appens, control never goes on next code line , and browser forever loading


回答1:


Sometimes the word.interop can cause the word document it has previously opened to become corrupt (if for example it did not save and close properly). This is not easily detected and word interop will behave as you have described. I have faced the same problem before. Try to delete the template file you are trying to open. Replace it with a new file. see if this helps at all.



来源:https://stackoverflow.com/questions/16916416/interop-word-documents-open-stuck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!