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.
Ivan VasilyevPosted Jun 13, 2014, 5:34 AM
Also to add another way that you can try to read your Word files with C# code is this simple approach:
The code uses this C# DLL for word files.
Monica JeevanPosted Sep 24, 2008, 1:50 AM
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?
Jan MontanoPosted Aug 2, 2007, 11:06 PM
ArtemPosted Aug 1, 2007, 6:30 AM
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 MontanoPosted Aug 1, 2007, 5:52 AM
ArtemPosted Aug 1, 2007, 5:42 AM
As I understand, two problems was because of new ver. of Word object model....
Thank you! :)
Jan MontanoPosted Jul 31, 2007, 6:00 AM
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;?"
ArtemPosted Jul 31, 2007, 5:35 AM
ArtemPosted Jul 28, 2007, 4:40 AM
ArtemPosted Jul 25, 2007, 4:12 AM
Well, I'll try to read your second link and then post again... But "using Word;" doesn't work now(((
Jan MontanoPosted Jul 25, 2007, 3:29 AM
Are you using Firefox? the editor is like an html editor, so you must include tags like < br > for a new line.
ArtemPosted Jul 25, 2007, 2:11 AM
Jan MontanoPosted Jul 25, 2007, 12:00 AM
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
ArtemPosted Jul 24, 2007, 5:58 AM
Jan MontanoPosted Jul 24, 2007, 4:25 AM
Here's to get you started: How to read a doc file