Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do i convert .DOC (word document) to A text file (.txt)

.DOC to .TXT

how do i convert it in c# ..
??
Posted
Updated 9-Jun-10 6:06am
v2

Google "C# Office SDK". You should be able to find guidance.
 
Share this answer
 
Comments
[no name] 13-Jun-10 6:42am    
Reason for my vote of 1
not answer
Abhishek Sur 13-Jun-10 16:32pm    
@aaser

I think this is a smart answer. You shouldnt be voting as 1 for this.
try this

C#
private string ReadDocFile(object sPath, ref string sDocContent)
{
    Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
    object missing = System.Reflection.Missing.Value;
    Word._Document aDoc = null;
    aDoc = wordApp.Documents.Open(ref sPath, ref missing, ref readOnly, ref missing, ref missing, ref missing,_ 
 ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,_ 
 ref missing, ref missing, ref missing);
    aDoc.Activate();
    aDoc.ActiveWindow.Selection.WholeStory();
    aDoc.ActiveWindow.Selection.Copy();
    IDataObject data = Clipboard.GetDataObject();
    sDocContent = data.GetData(DataFormats.UnicodeText).ToString();
    wordApp.Documents.Close(ref isNoSave, ref missing, ref missing); ;
    wordApp.Quit(ref isNoSave, ref missing, ref missing);
    return (string)sDocContent;
}
 
Share this answer
 
v3
Comments
Dalek Dave 13-Jun-10 10:10am    
edited to add line breaks on VERY long line.
Thanks, I'll try & hope so :(

thx for help
 
Share this answer
 
Comments
Toli Cuturicu 13-Jun-10 6:20am    
Reason for my vote of 1
fake answer
Abhishek Sur 13-Jun-10 16:33pm    
Reason for my vote of 1
Yes. This is not an answer. Should be made as comment

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900