Question : MS Access 2007 VBA to convert a Word document into a Text file

We receive registration forms through MS Word and we need to import them into MS Access.  Is there VBA code to transfer a Word document into a text file?  A text file is easier to import.

Answer : MS Access 2007 VBA to convert a Word document into a Text file

See VBA code.

If you're using from within Access, you'll need to make a reference to the Word library.

Change the first file path to your Word doc.  Second to your TXT name.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Dim w As New Word.Application
Dim doc As Word.Document

filePath = "c:\..\test.doc"
filePathTxt = "c:\..\test.txt"


Set doc = w.Documents.Open(filePath)

doc.SaveAs FileName:=filePathTxt, FileFormat:=wdFormatText, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False, Encoding:=1252, InsertLineBreaks:=False, AllowSubstitutions:=False _
    , LineEnding:=wdCRLF
        
Random Solutions  
 
programming4us programming4us