Page 1 of 1

DOCXReadWrite Get Text To String

Posted: Sun May 29, 2022 11:58 pm
by Effi
Hello, how can I read text from file .doc .docx or .txt in Memo1 or String ?

Code: Select all

procedure TfrmMain.Button1Click(Sender: TObject);
var
FDOCX: TDOCXReadWrite;
Str:String;
begin
FDOCX := TDOCXReadWrite.Create(Nil);
if opendialog1.Execute then
FDOCX.LoadFromFile(opendialog1.filename);
memo1.Lines.Add(FDocx.Editor.PlainText); // Not True ???
Str:=FDocx.Editor.PlainText; // Not True ???
FDOCX.Free;
end;

Re: DOCXReadWrite Get Text To String

Posted: Thu Jun 02, 2022 10:41 am
by larsa
Hello

Your code shall work assuming there is any text in the document. Please try first with a very simple DOCX file.