Welcome! Log In Create A New Profile

Advanced

Converting a .DOC file to .TXT

Posted by Gianni Spano 
Gianni Spano
Converting a .DOC file to .TXT
March 06, 2009 11:29PM
Hello to all

I'm not reinventing the wheel, but i would like to give my little contribution to other users whose can need to convert a .doc file to .txt to retrieve some data.

My little project:

- Put 2 Textboxes control in a window (one for the input and other for output filename)
- Put 2 buttons (convert and close)

in the "convert" button put these few lines of code:
//---------------------------------------------------------------------
autWord_server is object Automation "word.application"

autWord_server>>documents>>open (EDT_Edit1)

autWord_server>>ActiveDocument>>SaveAs (EDT_Edit2,2) //the '2' is corresponding to "save as Text file" from Winword
autWord_server>>Quit //to stop Winword execution in background
//----------------------------------------------------------------------

This little idea come from a needed to read some data stored in a lot of MsWord files and instead to read every file using an OleAutomation approach that could have some difficult, i prefered to convert them as text file and read each file line by line.

Hope to help someone whit this little solution,.

Gianni
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: