0

i want to add a word document into c sharp code as reference..and while clicking a button in the form,the word file has to get opened..

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by tgreer
0

Use Process.Start() to open a file.

static void Main()
    {
	// A.
	// Open specified Word file.
	OpenMicrosoftWord(@"C:\Users\Sam\Documents\Gears.docx");
    }

    /// <summary>
    /// Open specified word document.
    /// </summary>
    static void OpenMicrosoftWord(string f)
    {
	ProcessStartInfo startInfo = new ProcessStartInfo();
	startInfo.FileName = "WINWORD.EXE";
	startInfo.Arguments = f;
	Process.Start(startInfo);
    }

you can even run an exe file by using Process.Start()

Process.Start("sample.exe");
0

but i have to run this code in different computers.so giving the path by default is not possible right..can i add the word document to my code and display it later by pressing a button in the form.

0

Rather adding the document to you code, add the file to your project and deploy it in other computers!!

0

Actually i am supposed to send only exe file and dll..is there no other way?

0

It sounds to me like you would need to create the MS-WORD document in code, stream it out to a temporary location determined by your application, then open it.

The Web abounds with examples of creating Office Documents in .NET.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.