Solved

Dump *.Doc  to Text ?

Posted on 2010-11-26
5
358 Views
Last Modified: 2012-05-10
Im looking for a free or opensource component to Dump *.Doc  to Text ?

Please do not post unless you have a free or opensource method of accomplishing this.

THanks
0
Comment
Question by:Looking_4_Answers
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:DonConsolio
Comment Utility
0
 

Author Comment

by:Looking_4_Answers
Comment Utility
Sorry, Delphi 2010
0
 

Author Comment

by:Looking_4_Answers
Comment Utility
@DonConsolio:

NO THANKS


Actually, i would be more interested in plain ole code versus a component
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
Simply you can use the following code to open the doc file and copy the content to memo and/or text file:

uses ComObj, clipbrd;



procedure TForm1.Button1Click(Sender: TObject);

var

  WordApp : Variant;

  Range : Variant;

  i : integer;

  Selection : Variant;

begin

  WordApp := CreateOleObject('Word.Application');

  WordApp.Visible := false;

  Wordapp.documents.open('C:\YouDocFile.doc');

  Range := WordApp.Documents.Item(1).Range;

  WordApp.documents.item(1).select;

  WordApp.selection.copy;

  Memo1.lines.clear;

  Memo1.pastefromclipboard;

  Clipboard.Clear;

  Memo1.Lines.SaveToFile('C:\YouTextFile.txt');

  WordApp.documents.item(1).Close;

  WordApp.Quit;

end;

Open in new window

0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
Comment Utility
Here is the code for converting without using the clipboard:

uses ComObj;

procedure TForm1.Button1Click(Sender: TObject);
const
  wdDoNotSaveChanges = 0;
var
  WordApp : Variant;
  Range : Variant;
begin
  WordApp := CreateOleObject('Word.Application');
  WordApp.Visible := false;
  Wordapp.documents.open('C:\YouDocFile.doc');
  WordApp.Selection.ClearFormatting;
  Range := WordApp.Documents.Item(1).Range;
  WordApp.documents.item(1).select;
  Memo1.Lines.Text := WordApp.selection.text;
  Memo1.Lines.SaveToFile('C:\YouTextFile.txt');
  WordApp.ActiveDocument.Close(wdDoNotSaveChanges);
  WordApp.Quit;
end;

Open in new window

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now