We need to open a word document which is located on a server on the clients machine using Microsoft Word. The solution is working locally however when deployed on server then on
You have to keep in mind that the client and server are running on two different machines. The server can't start a program running on the client machine.
Also, FYI, never use Office Automation from an ASP.NET application. Those APIs were designed for use in a desktop application. They won't work properly, are unsupported, and may even violate your Office license.
<script language="javascript" type="text/javascript">
function openDokument(dokument){
var objAppl;
try{
objAppl = GetObject("","Word.Application");
objAppl.Documents.open(dokument);
}
catch(exception){
objAppl = new ActiveXObject("Word.Application");
objAppl.Visible = true;
alert(dokument);
objAppl.Documents.open(dokument);
objAppl.Activate();
}
objAppl = null;
}
</script>
You can use the DocX class to create your word doxument. Then the Response.Write() method (precise that the doxument extension is .docx) to download the document in your machine
The reason it is working locally, is because, well, it isn't. What's happening is that the server is opening the document, but because your local machine is acting as the server it appears as if the file is opened.
One simple solution is for the user to download the file, edit it and upload it back to you.