sprinken
asked on
Get the count of the words in a txt/rtf/doc file
The title says what I want? For a text file it's easier to get the word count but how can I do the same thing for a rtf or doc file?
Regards,
Sprinken
Regards,
Sprinken
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
where buy.txt is where the filename will go.
procedure TForm1.Button1Click(Sender : TObject);
begin
RichEdit1.Lines.LoadFromFi le(filenam e);
RichEdit1.PlainText := true;
RichEdit1.Lines.DelimitedT ext := RichEdit1.Text;
ShowMessage('You have '+IntToStr(RichEdit1.Lines .Count)+' words.');
end;
end.
procedure TForm1.Button1Click(Sender
begin
RichEdit1.Lines.LoadFromFi
RichEdit1.PlainText := true;
RichEdit1.Lines.DelimitedT
ShowMessage('You have '+IntToStr(RichEdit1.Lines
end;
end.
- load the file content into a TRichEdit component:
if OpenDialog1.Execute then
RichEdit1.Lines.LoadFromFi
- set the property:
RichEdit1.PlainText := True;
- S := RichEdit1.Text; // contains the text without formatting symbols, you may count the words !