954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C# code to open word documents in visual studio 2010

hi! i want to open a word document directly from a windows form application running on visual studio 2010!
i tried a particular code but it wont work!!!
this is the code!

this.Application.Documents.Open(@"C:\Test\NewDocument.doc");

i also imported and used the following header:

using Microsoft.Office.Interop.Word;


it says that the word application does not exists!
Can anyone help me out with this

thanks in advance!

Mirfath
Light Poster
28 posts since Oct 2011
Reputation Points: 10
Solved Threads: 2
 

hi! i want to open a word document directly from a windows form application running on visual studio 2010! i tried a particular code but it wont work!!! this is the code!

this.Application.Documents.Open(@"C:\Test\NewDocument.doc");

i also imported and used the following header:

using Microsoft.Office.Interop.Word;

it says that the word application does not exists! Can anyone help me out with this

thanks in advance!

Did you check if Word is installed on the particular computer? And you can always use Process.Start to start a program/open a document. Here is some more information about how to open a word document in C#: http://omegacoder.com/?p=555

Three
Newbie Poster
11 posts since Nov 2011
Reputation Points: 31
Solved Threads: 4
 

yes i have installed word 2010
the link you gave me
visual studio errors under application,document and selection saying that you can use it as an instatnce

Mirfath
Light Poster
28 posts since Oct 2011
Reputation Points: 10
Solved Threads: 2
 

thanks it worked i used a different code!

Mirfath
Light Poster
28 posts since Oct 2011
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: