I try this code
string[] ext = att.Name.Split('.');
string file = ext[0].ToString();
object Target = file + ".txt";
object nullobject = System.Reflection.Missing.Value;
Application.Documents.Open(ref FileName, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref value, ref value, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatUnicodeText;
Application.ActiveDocument.SaveAs(ref Target, ref format,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown);
Application.Visible = false;
Microsoft.Office.Interop.Word.Document oDoc1 = Application.ActiveDocument;
string strNewDocText1 = oDoc1.Content.Text;
But in strNewDocText1 get output including bullets and extra word formate
I want to simple plain-text format of my word document into text documnt.
I believe you took this example from here: http://www.codeproject.com/Articles/5273/How-to-convert-DOC-into-other-formats-using-C
So basically you have a RTF, which must be convert to plain text. Here is an example
Simplest approach is just to add reference to System.Windows.Forms.dll.
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
string richText = text// The rich text (with bullets and so on.)
rtBox.Rtf = richText ;
string plainText = rtBox.Text;
System.IO.File.WriteAllText(@"output.txt", plainText);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With