Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am working on a projec that is almost to an edge (its in C# language).
I have used microsoft Excel and Microsoft Power Point as an utility.
it works perfectly in my application but after deploying the project it was not working.

following is the code for the same.
please help me.

CODE

C#
try
{
    //p = new Process();
    //p.StartInfo.FileName = "winword";
    //p.Start();


    System.Diagnostics.Process myProces = new System.Diagnostics.Process();
    myProces.StartInfo.FileName = "C:\\Program Files\\Microsoft Office\\Office12\\winword";
    myProces.Start();
    //myProces.Kill();
}
catch (Exception ex)
{
    Response.Write("<script>alert('Microsoft Word is not installed.');</script>");
}
Posted
Updated 8-Apr-11 18:18pm
v2

Depending on the system you can find the install location for example in 32 bit environment from:
HKLM\SOFTWARE\Microsoft\Office\14.0\Word\InstallRoot\Path

and 64 bit
HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Word\InstallRoot\Path

The path is version dependent so use the correct version number.
 
Share this answer
 
Comments
Vandana87 9-Apr-11 7:11am    
thank you for your guidance
Wendelius 9-Apr-11 7:18am    
You're welcome
Vandana87 16-Apr-11 0:51am    
MS office works properly in Compile time that is whn the project is not deployed,but after Deployment it doesn't work.no action is seen after user clicks on menu bar option plz guide me.
Wendelius 16-Apr-11 2:46am    
You can always post a new question. In that post include the error messages if any. Also before posting the question modify your code so that you check if the process start gives an error and check that output on the deployment machine.
The most obvious question:

Has the computer you deployed you application to got Office installed? If so, is it installed in the place you are expecting? Hardcoding locations like that is a bad move, since you cannot guarantee that the installation directory is the same...


"thank you for the reply.
i have just given the default path of MS Excel&Ppt.so plz guide me if there is some other way .if possible plz give the code for the same.
yes i know that there would a case were the default directory would be different in some cases but i dont know how to go the other way.
please help me."


Don't give a path at all! If it is installed, Windows should know where it is:
ProcessStartInfo runMe = new ProcessStartInfo();
runMe.FileName = "WINWORD.EXE";
//runMe.Arguments = "myArguments";
Process.Start(runMe);
Try it: you will see what I mean...:laugh:

[edit]Oops - I can't even spell "arguments" today... - OriginalGriff[/edit]
 
Share this answer
 
v3
Comments
Vandana87 9-Apr-11 2:42am    
thank you for the reply.
i have just given the default path of MS Excel&Ppt.so plz guide me if there is some other way .if possible plz give the code for the same.
yes i know that there would a case were the default directory would be different in some cases but i dont know how to go the other way.
please help me.
OriginalGriff 9-Apr-11 3:09am    
Answer updated
Vandana87 9-Apr-11 7:10am    
thank you for your guidance
Vandana87 16-Apr-11 0:49am    
MS office works properly in Compile time that is whn the project is not deployed,but after Deployment it doesn't work.no action is seen after user clicks on menu bar option plz guide me.

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