How do I display a Word document in a rich-edit control?

5.3k Views Asked by At

I'm building a Delphi app and I want to read a Word document and display it in a rich edit. How can I do that?

2

There are 2 best solutions below

0
On

If you are considering a 3rd party control that can accomplish this, RichView allows you to import word documents.

http://www.trichview.com/

I believe it uses word itself to do the importing, so your target machines will have to have it installed to be able to import.

1
On
function OpenWordFile(const FName: string): string;
var wordText: string;
begin
  openWord := CreateOleObject('Word.Application');
  openWord.Visible := False;
  openWord.Documents.Open(FName);
  openWord.ActiveDocument.Select;
  wordText:= openWord.Selection.Text;
  openWord.ActiveDocument.Close;
  openWord.Quit;
  openWord := unassigned;
  /////
  Result:= wordText;
end;