convert word file to text file

grizzlyjdw2

Registered User.
Local time
Today, 15:51
Joined
Feb 26, 2009
Messages
22
anyway to convert a .doc file to a .txt file and remove all of the formating? when i use saveas from the word document object, i get the text file but there is still garbage in it.

is there anyway to make the text file be the same as if you opened it in word and did save as txt?
 
anyway to convert a .doc file to a .txt file and remove all of the formating? when i use saveas from the word document object, i get the text file but there is still garbage in it.

is there anyway to make the text file be the same as if you opened it in word and did save as txt?

This seemed to work for me.
Code:
Sub wrdDocTest()
Dim wd As Word.Application
Dim wDoc As Word.Document
Set wd = New Word.Application
Set wDoc = wd.Documents.Open("C:\temp\My.doc")
Call wDoc.SaveAs("C:\temp\My.txt", wdFormatDOSText, , , , , , , , , , , True, True)
wDoc.Close
Set wDoc = Nothing
wd.Quit
Set wd = Nothing
End Sub
 
that worked GREAT :)

just one more question, is there anyway to keep the file name and not have to specify it?

for example if i have test.doc can i have it automatically output to test.txt and then do that for each file name if i am going through a directory?
 
nevermind, answered my own question :)

just use the & operator when passing to a function and you can use the same file name :)

thanks for the help
 

Users who are viewing this thread

Back
Top Bottom