2011-01-10 11 views
1

Word文書があり、RTF(またはHTML)形式のコンテンツをエクスポートしたいと思います。WordからRTFを取得する

 Word.Application wordApp = new Word.Application(); 
     Word.Document currentDoc = wordApp.Documents.Open("file.docx"); 
     currentDoc.SaveAs("file.rtf", Word.WdSaveFormat.wdFormatRTF); 
     currentDoc = wordApp.Documents.Open("file.rtf"); 
     Word.Range range = currentDoc.Range(); 
     String RTFText = range.Text; 

私は上記のコードを試しましたが、私はhteフォーマットなしでTextを取得するようです。

アイデア?あなたのために動作しませんあなたの方法を使用して

string rtf = File.ReadAllText("file.rtf"); 

:通常のテキストファイルのようにそれを開き

Word.Application wordApp = new Word.Application(); 
Word.Document currentDoc = wordApp.Documents.Open("file.docx"); 
currentDoc.SaveAs("file.rtf", Word.WdSaveFormat.wdFormatRTF); 

そして:あなたはRTFコードを読みたい場合は

答えて

3

は、単に使用するようにしてくださいというプロパティにアクセスしているため、Wordではプレーンテキストしか表示されません。

+0

私は複雑な方法を考えていました。ありがとう! – Jaster

関連する問題