Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatically converting .doc file to .txt file 1

Status
Not open for further replies.

Painkiller

Programmer
May 18, 2001
97
NL
Hi all,

I'm currently working on a project where data is read from a Word file to store in a database. In order to ease the extraction of data I've converted the Word file to a .txt file. It is however user unfriendly to ask the user to first convert the file himself. So I'm looking for a way to make sure that when the user selects a file (using a dialogwindow) the file is automatically converted to a .txt file. Does anybody know how to go about this? I think the easiest way would be to use a Word object, but I don't know what commands to use for the convertion part.

any help would be greatly appreciated
 
Here is one way you can start Word from VB. Make sure that you include the Microsoft Word Object Library in your project references. To see all of the details of the Open function, just record a macro while opening a document. You can use the Microsoft Common Dialog Control (Project Components) to utilize the standard FileOpen dialog box as the user interface to select the Word document.
Code:
Dim wdApp As Word.Application

Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.WindowState = wdWindowStateMaximize
wdApp.Documents.Open ...
To convert to a .txt file, the easiest way to get the code is to record a macro while performing the task.
Code:
Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top