A
admin4office
The following VBA script opens Word documents in the directory C:\src, and
saves their contents as text files in the directory C:\dest. Unfortunately,
the saved text files include Word formatting, which crimps my plan to index
the contents with Perl. I would much rather that the files be saved as plain
text. The line that I think needs fixing is indicated with an arrow
(<----**). Does anyone have any ideas? Thanks much.
Sub SaveAllWord()
Dim srcPath As String
Dim destPath As String
Dim sName As String
Dim dt As Document
srcPath = "C:\src\"
destPath = "C:\dest\"
sName = Dir(srcPath & "*.doc")
Do
Set dt = Documents.Open(srcPath & sName)
dt.SaveAs
ActiveDocument.SaveAs destPath & dt.Name & ".txt", _
FileFormat = wdFormatText '<----**
ActiveDocument.Close SaveChanges:=False
sName = Dir()
Loop While sName <> ""
End Sub
saves their contents as text files in the directory C:\dest. Unfortunately,
the saved text files include Word formatting, which crimps my plan to index
the contents with Perl. I would much rather that the files be saved as plain
text. The line that I think needs fixing is indicated with an arrow
(<----**). Does anyone have any ideas? Thanks much.
Sub SaveAllWord()
Dim srcPath As String
Dim destPath As String
Dim sName As String
Dim dt As Document
srcPath = "C:\src\"
destPath = "C:\dest\"
sName = Dir(srcPath & "*.doc")
Do
Set dt = Documents.Open(srcPath & sName)
dt.SaveAs
ActiveDocument.SaveAs destPath & dt.Name & ".txt", _
FileFormat = wdFormatText '<----**
ActiveDocument.Close SaveChanges:=False
sName = Dir()
Loop While sName <> ""
End Sub