从asp.net应用程序打开和编辑Word文档 [英] opening and editing word document from asp.net application

查看:93
本文介绍了从asp.net应用程序打开和编辑Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Web应用程序(asp.net),需要在其中打开和编辑Word文件.
我编写了我在Winform应用程序中测试过的C#代码(并运行得很好).

当我尝试在asp.net应用程序中使用它时,出现错误:
1.我没有使用模拟,也无法使用以下命令打开Word文件:

Hi,

I have a web application (asp.net) in which I need to open and edit a word file.
I wrote c# code which I tested (and worked perfectly fine) in a winform application.

When I tried to use it in my asp.net application I got errors:
1. I didn''t use impersonate, and I couldn''t open the word file using the following command:

Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);



我收到此错误:
由于以下错误,检索具有CLSID {000209FF-0000-0000-C000-000000000046}的组件的COM类工厂失败:80070005访问被拒绝.

我尝试按照以下步骤修复它(仍然不使用模拟):
http://stackoverflow.com/questions/3477086/access-office-word-object-model-through-asp-net-results-in-failed-due-to-the [ http://social.msdn.microsoft.com /Forums/zh-CN/netfxbcl/thread/006cbbac-101a-40ea-ae16-d59a7a2da8b1/ [



I got this error:
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied.

I tried fixing it (still without using impersonate), following this:
http://stackoverflow.com/questions/3477086/accessing-office-word-object-model-through-asp-net-results-in-failed-due-to-the[^]

and this:
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/006cbbac-101a-40ea-ae16-d59a7a2da8b1/[^]

I couldn''t find the WINWORD.EXE that they were talking about under the given directory, and also couldn''t find the CLSID in the DCOM Config

2. I tried using the impersonate, and added the administrator userID and password

<identity impersonate="true" userName="domain\Administrator" password="password" />



然后打开了文档文档,但由于出现以下错误,我根本无法使用该文档:
消息过滤器指示应用程序正忙. (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))

据我所知,它的发生是由于以下两个原因之一:
一个.有某种弹出式窗口阻止编辑文档(因为它尚未真正打开)
b.实际上,假冒者对此负责,因为我使用一个标识打开文件,然后尝试使用另一个标识进行编辑

我不能同时执行以下两个命令:



Then the doc WAS opened, but I couldn''t use the document at all due to the following error I got:
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

As I figured it, it happens because one of 2 reasons:
a. There''s some kind of popup that prevents editing the document (since it''s not really open yet)
b. The Impersonate actually is responsible for that, since I open the file with one identity and try to edit it with another

I couldn''t do neither of the following commands:

doc.Save();


doc.Activate();


for (int i = 1; i < doc.Sections.Count + 1; i++)


(在最后一个中,它无法获取部分)

任何人都知道我如何解决此问题(如果可能,我宁愿不使用假冒用户)

谢谢


(In the last one it fails getting the sections)

Anyone knows how I can resolve this issue (I prefer not using the impersonate, if possible)

Thanks

推荐答案

[ ^ ]链接可能会很有用.在Google上进行的快速搜索也发现了其他一些内容. WinWord.exe 是Word可执行文件:您应该能够在Program Files \ Microsoft Office文件夹中找到它.祝你好运.
This[^] link might be useful. A quick search on Google found a few others as well. WinWord.exe is the Word executable: you should be able to find it in the Program Files \ Microsoft Office Folder. Good luck.


您好,请检查以下两个链接:

来自ASP.NET的Microsoft Word文档 [总结C#控制字技能 [
Hi, check the two links below:

Microsoft Word Documents from ASP.NET[^]

Summarize C# Control Word Skills[^]


我有为此问题做了一个例子,

有关步骤和代码,请单击此链接-

http://steptodotnet.blogspot.in/2012/11/how-to-edit-word-document-using-aspnet.html
I have done one example for this problem ,

for steps and code follow this link-

http://steptodotnet.blogspot.in/2012/11/how-to-edit-word-document-using-aspnet.html


这篇关于从asp.net应用程序打开和编辑Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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