Read .doc files
Hi! I have a problem.. I don't know how to read MS Word file (*.doc) in Visual Studio C# Windows Application... StreamReader in such situation of course not working...(((
Is anybody know how to solve this problem.... Now I'm using VS 2008 beta1, but in C# there everithing the same like in VS 2005...
Thanks.

Jan MontanoRank #1,295 · 1.3K reputationPosted Jul 24, 2007, 12:25 AM EDT
Here's to get you started: How to read a doc file
Artem48 reputationPosted Jul 24, 2007, 1:58 AM EDT
Jan MontanoRank #1,295 · 1.3K reputationPosted Jul 24, 2007, 8:00 PM EDT
You must add a reference first to the Microsoft Word Object Library. If you don't know how, Right click your project then select Add Reference. You'll find the Component under the COM tab.
Additional info: Word Object Model
You're english is ok. And if it's not, there's no need to be sorry about ^_^. It's expected here at the forum that we come from different places with different languages. :)
Cheers Mate,
Jan
Artem48 reputationPosted Jul 24, 2007, 10:11 PM EDT
Jan MontanoRank #1,295 · 1.3K reputationPosted Jul 24, 2007, 11:29 PM EDT
Are you using Firefox? the editor is like an html editor, so you must include tags like < br > for a new line.
Artem48 reputationPosted Jul 25, 2007, 12:12 AM EDT
Well, I'll try to read your second link and then post again... But "using Word;" doesn't work now(((
Artem48 reputationPosted Jul 28, 2007, 12:40 AM EDT
Artem48 reputationPosted Jul 31, 2007, 1:35 AM EDT
Jan MontanoRank #1,295 · 1.3K reputationPosted Jul 31, 2007, 2:00 AM EDT
I'm just here in the dark. Have you already tried the first link I posted? That's basically what you need to read a .doc file. What problem are you encountering now? What error did you encounter with "using Word;?"
Artem48 reputationPosted Aug 1, 2007, 1:42 AM EDT
As I understand, two problems was because of new ver. of Word object model....
Thank you! :)
Jan MontanoRank #1,295 · 1.3K reputationPosted Aug 1, 2007, 1:52 AM EDT
Artem48 reputationPosted Aug 1, 2007, 2:30 AM EDT
openFileDialog1.ShowDialog(); - no problem
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass(); - (1) what we do here?
object file = Path.GetFullPath(openFileDialog1.FileName); - (2) what is Path? What we create here?
object nullobj = System.Reflection.Missing.Value; - (3) what is nullobj?
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory(); - (4) What is it? What is "ActiveWindow" and "WholeStory"?
doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject(); -(5) what is the "IDataObject"? And what we Get here?
txtFileContent.Text = data.GetData(DataFormats.Text).ToString();
doc.Close(ref nullobj, ref nullobj, ref nullobj);
Ok! If it possible, answer me to the (1) - (5) answers... I need to understand this ...
Jan MontanoRank #1,295 · 1.3K reputationPosted Aug 2, 2007, 7:06 PM EDT
Monica Jeevan2 reputationPosted Sep 23, 2008, 9:50 PM EDT
Hi I am new to this site. I too am facing the same problem like you. I need to read a doc file. I followed the same steps as you did. but I get an error in "Using Word" and "Using Office" . I have included the reference - Microsoft Word 12.0 Object Library. it does not work. what do i have to do?
Ivan Vasilyev10 reputationPosted Jun 13, 2014, 1:34 AM EDT