SparceMatrix
02-15-2006, 01:36 PM
I am tryng to use Word to convert some documents from Word/HTML to text using Windows Script Hosting. I find that using this code in a Module in Word's VBA functionality works fine:
Sub Works()
Set Doc = Documents.Open( _
ReadOnly:=False, _
FileName:="C:\....\MyDocFile.doc" _
)
Doc.SaveAs _
FileName:="C:\...\MyTextFile.txt", _
FileFormat:=wdFormatText
Doc.Close
End Sub
But now back to Windows Script Hosting and I find a few new problems. First, the named argument functionality does not work and I can't find any reference to the reason in MSDN's on line documentation. And also, this adaptation to a Windows Script Hosting script does not work:
' VB Script Document
Sub Works()
Set Word = CreateObject("Word.Application")
Set Doc = Word.Documents.Open( _
"C:\....\MyDocFile.doc" _
)
Doc.SaveAs _
"C:\...\MyTextFile.txt", _
wdFormatText
Doc.Close
End Sub
Works()
If I open MyTextFile.txt, I see a lot of gibberish -- not text and if I open the document in Word, it looks just like the original.
Anybody have any idea what is going on? Any and all tips or clues would be appreciated.
Sub Works()
Set Doc = Documents.Open( _
ReadOnly:=False, _
FileName:="C:\....\MyDocFile.doc" _
)
Doc.SaveAs _
FileName:="C:\...\MyTextFile.txt", _
FileFormat:=wdFormatText
Doc.Close
End Sub
But now back to Windows Script Hosting and I find a few new problems. First, the named argument functionality does not work and I can't find any reference to the reason in MSDN's on line documentation. And also, this adaptation to a Windows Script Hosting script does not work:
' VB Script Document
Sub Works()
Set Word = CreateObject("Word.Application")
Set Doc = Word.Documents.Open( _
"C:\....\MyDocFile.doc" _
)
Doc.SaveAs _
"C:\...\MyTextFile.txt", _
wdFormatText
Doc.Close
End Sub
Works()
If I open MyTextFile.txt, I see a lot of gibberish -- not text and if I open the document in Word, it looks just like the original.
Anybody have any idea what is going on? Any and all tips or clues would be appreciated.