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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert a .doc to .txt

Status
Not open for further replies.

ASUHOCKEY18

Programmer
Jul 10, 2003
4
US
I am very new with VBA, and need some help with code on how to take an existing word document (.doc) and change it into a file with a .txt extension within an Access module so I can parse it easily... I know it sounds a little backwards, but if any one could help I would appreciate it!
 
This is from
It does NOT cover Access; but if you also look at
faq702-2379
on this forum, it might give you some ideas on how to tweak the code to make it work for you.

I would imagine you will have to alter
objWD.ActiveDocument.SaveAs filename:="mydoc.doc"
to include a command to save it as a text file.

Sub AutomateWord()
' Declare the variable.
Dim objWD As Word.Application
' Set the variable (runs new instance of Word.)
Set objWD = CreateObject("Word.Application")
' Add a new document.
objWD.Documents.Add
' Add some text.
objWD.Selection.TypeText "This is some text."
' Save the document.
objWD.ActiveDocument.SaveAs filename:="mydoc.doc"
' Quit Word.
objWD.Quit
' Clear the variable from memory.
Set objWD = Nothing
End Sub

"A great many people now reading and writing would be better employed keeping rabbits." --Dame Edith Sitwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top