I use the following code snippet to open a local docx file and it runs fine when I press Ctrl+F5 in Visual Studio. I just click the button and the Word2007 on my machine is opened and the docx is displayed there. But after I publish the application to the production server, it didn’t work. After I click the same button, nothing happened. Could someone tell me why?
What I want is to open a local stored docx in client side’s Word 2007 from asp.net application. I don’t want to use office COM object.
My code:
ProcessStartInfo psi = new ProcessStartInfo(@"winword.exe",@"/test.docx");
Process.Start(psi);
Many thanks.
Your code is attempting to open Word on the server and not on the client. The only reason it works in development is the the client and server are on the same machine.
You cannot open Word on the client due to browser security restrictions. However if you provide a link to the file, the user will be able to download and open the file if they have Word installed.