Saving Word as text

K

Kas

I need code to open each document in a specific directory
and save them as text files. Any help on this would be
greatly appreciated.
 
J

Jezebel

It would be easier to help if you provided some information about the
problem. What have you tried so far?
 
J

Joseph

Copy the below macro code into your normal.dot template and try it.


Sub Report()

With Application.FileSearch
.NewSearch
.FileType = msoFileTypeAllFiles
.LookIn = "d:\data" 'Path to the folder having the documents
.Execute
TotalFiles = .FoundFiles.Count
For i = 1 To TotalFiles
Documents.Open .FoundFiles(i)
myname = .FoundFiles(i)
X = ActiveDocument.Name
pos = InStrRev(myname, ".doc")
s = Left(myname, pos - 1)
ActiveDocument.SaveAs Filename:=s & ".txt",
FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False,
_
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
ActiveWindow.Close
Next i
End With

End Sub



HTH,
Stephen
http://crosssoft.netfirms.com
 

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