Click here to Skip to main content
15,881,732 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I want to read a docx file in asp.net appliaction I have used code which is working fine on local machine.but on deploying on server it give error like This
---------- command is not available because no document is open.
Posted
Updated 25-Jun-12 3:27am
v3

When you tested it on the local machine, your were running with the client and the server on the same PC. Which also had Office installed.

Now, you are running it on a server which may or may not be in the same side of the world from your client, and which in all lieklyhood does not have office installed.

And you expect it to work.

The commands are executed on the server. So the process is opened on the server. If it has Office installed, it will open the document. On the server. Where you as the client can't see it.

Processes executed on the server stay there. You cannot (without producing an ActiveX control and somehow persuading the client to install it and Office) run a process on the server to open a document on the client. Period.

If you need the client to open a document, send it to them.
 
Share this answer
 
Comments
atul tr 25-Jun-12 9:39am    
Thanks for ur ans... but i m configuring on my systems iis server...
when i m running the application using visual studio it works but after putting the appliaction in c----wwwroot and when running with inetmgr as localhost it wont work pls suggest me what to do..
Based upon the fact that it worked on your local machine but not on the server, the first place you should check should be the file path. Local paths don't always translate to server paths. Figure out what path you are using to open the document on the server and then try to access the document yourself using that path.

Next, do you have Microsoft Word installed on the server? If you are using the Interop libraries, I believe you need to have a full copy of Word installed on the server in order for it to work.

Finally, do you have error checking in place? It looks like you might have eaten an error earlier in the open document process. If so, you could have allowed the processing to continue even after the error. This would allow you to go to this point before the next error stopped you cold. Check your error handling and see if the document is properly loading before you get to this point. Maybe it sees the document but cannot open it for some reason (wrong version, bad permissions, etc.)
 
Share this answer
 
Comments
atul tr 26-Jun-12 2:05am    
i have checked all the file paths. the error occured at the openining the word file using this statement..

Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref fileName,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj);
Tim Corey 26-Jun-12 8:28am    
You are going to need to walk this through, I cannot since I am not there. Read through my post and follow my questions. First, is Word installed on the server (a must in order to use Interop)? Second, can you browse to the file path (via URL)? Third, are you trapping any errors that you should be exposing?

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