Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

C#
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);


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
XML
<identity impersonate="true" userName="domain\Administrator" password="password" />


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:
C#
doc.Save();

C#
doc.Activate();

C#
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
Posted
Comments
[no name] 15-May-12 9:32am    
Is Word installed on the web server?
DanaH85 16-May-12 2:18am    
yesterday I changed the Impersonate to work with the local administrator and I didn't get the second error. But I don't want to work with Impersonate...
Meaning now I need to solve the problem mentioned in (1) in my original message

Any suggestions?

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.
 
Share this answer
 
Comments
DanaH85 16-May-12 2:18am    
I put the two links I was using trying to to solve this issue...
I know where the WINWORD.EXE is found, but I was trying to locate it in the registry and couldn't find it there (I found about 20 libraries named "word...(something)" but I couldn't decide which one I have to change the CLSID value for...
 
Share this answer
 
Comments
DanaH85 16-May-12 2:18am    
Thanks, I saw the first one before I posted my question, the second one was new to me. Yet, I do know how to edit word files through code, but out of some reason I get this security alert and the file won't be opened
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
 
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