DOCXReadWrite Get Text To String

Questions and answers on how to use DOCXReadWrite
Post Reply
Effi
Posts: 1
Joined: Sun May 29, 2022 11:52 pm

DOCXReadWrite Get Text To String

Post 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;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: DOCXReadWrite Get Text To String

Post by larsa »

Hello

Your code shall work assuming there is any text in the document. Please try first with a very simple DOCX file.
Lars Arvidsson, Axolot Data
Post Reply