Save a Word document as .txt from within Access

C

Carol Grismore

Is there a way to save a Word document as a .txt file using VB code? I don't
want to ask my users to "save as" because they will be working with
thousands of documents on many different servers.
 
B

BeWyched

Hi

I assume you know how to automate Word from Access using VBA. If so, use the
SaveAs method,

e.g.

ActiveDocument.SaveAs FileName:="abc.txt", FileFormat:=wdFormatText

Cheers.

BW
 
C

Carol Grismore

Yep, tried that -- I bet you thought I gave you an easy one. The result is
not a .txt file. It looks like a .doc looks when you open it with Notepad.

Here's my code:

--------------------------------------------------------------------
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True

With WordApp
.Documents.Open "C:\Documents\file.doc"
Set WordDoc = WordApp.ActiveDocument

WordDoc.SaveAs _
FileName:="C:\Documents\file.txt", _
FileFormat:=wdFormatText

End With
 
C

Carol Grismore

Between us, we figgered it out. Your snip works, if the proper reference is
added to the project. I'm all set now, so thanks very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top