Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to open an existing word document, the execution happens
with no error but Word does not come up and my document does not open.

This is the code I am using..

Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\winword.exe");
        ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files\Microsoft Office\OFFICE11\winword.exe");   



I used another way to do this, but the result is same...the other way is used is

C#
protected void Button1_Click(object sender, EventArgs e)
    {
        CCWordApp test;
        test = new CCWordApp();
        test.Open(@"D:\Experiments\WordOpen\Letter\Brief India foutieve facturen.doc");

    }


public class CCWordApp
{
    private Word.ApplicationClass oWordApplic =new Word.ApplicationClass();	// a reference to Word application
	private Word.Document oDoc=new Word.Document();		
	public CCWordApp()
	{
		//
		// TODO: Add constructor logic here
		//
	}
            // Open a file (the file must exists) and activate it
        public void Open(string strFileName)
        {
            object fileName = strFileName;
            object readOnly = false;
            object isVisible = true;
            object missing = System.Reflection.Missing.Value;
            oWordApplic.Visible = true;
            oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing);
            oDoc.Activate();
         }

           
         }








Please Help me
Posted
Updated 5-Dec-11 21:34pm
v3

It does, you know.

But it opens on the SERVER, not the CLIENT. You cannot open any application on the client computer - that is known as "probably virus activity" and is heavily forbidden upon for security reasons.
 
Share this answer
 
Comments
kishore Rajendran 6-Dec-11 3:30am    
I did it on the server. I have a big application to use this, to test it, I wrote a small website and added to the IIS of the server, and am trying to open in the server itself. But its showing in the task manager,but not showing the document
MS Word is an application and it does not make sense to use it in a ASP.net web application for many reasons a few of which are :

- You will need to install office on your web server.
- Your users will not see Word UI.
- It is not scalable beyond 5 instances.

Generally this is a bad idea, you are better off using server side components for generating or processing DOC files.
 
Share this answer
 
Comments
kishore Rajendran 6-Dec-11 3:32am    
Yes i used many ways to do this, and the result is same. Its showing in task manager and not showing up the document

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