WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Word

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Convert an RTF File to Plain Text file using Word


Here is some code to convert an RTF file to plain Text file using Word.
in_fname = "c:\temp\test.rtf"
out_fname = "c:\temp\test.txt"

oWord = ObjectOpen( "Word.Application")
oWord.Visible = @TRUE  ;Change to @FALSE to hide

oDocs = oWord.Documents
oDocs.open( in_fname )
oActiveDocument = oWord.ActiveDocument

wdFormatText = 2
wdCRLF = 0
oActiveDocument.SaveAs(:: FileName=out_fname, FileFormat=wdFormatText, LockComments=0, Password="", AddToRecentFiles=1, WritePassword="", ReadOnlyRecommended=0, EmbedTrueTypeFonts=0, SaveNativePictureFormat=0, SaveFormsData=0, SaveAsAOCELetter=0, Encoding=1252, InsertLineBreaks=0, AllowSubstitutions=0, LineEnding=wdCRLF)

oDocs = 0
oActiveDocument = 0
oWord.Quit
oWord = 0
Exit

Article ID:   W17454
File Created: 2008:04:10:15:10:46
Last Updated: 2008:04:10:15:10:46