R
RayS
I need to convert HTML files to clean TXT files with line breaks. I tested
Word manually and it has this feature so I am trying to call that from within
VB6. I have written the following code which works except the destination
file format is always Word's default. Apparently the "fileformat" function of
the SaveAs line has something wrong but I need help determining what the
problem is? Any help would be appreciated.
Dim wrdApp As Object
Dim wrdDoc As Object
Dim strDocToOpen As String
Dim strDocToSave As String
strDocToOpen = "C:\Documents and Settings\Ray Smith\Junk\HTML test.htm"
strDocToSave = "C:\Documents and Settings\Ray Smith\Junk\HTML test.txt"
Set wrdApp = CreateObject("Word.Application")
wrdApp.WordBasic.DisableAutoMacros 'Disable any Macros
Set wrdDoc = wrdApp.Documents.Open(strDocToOpen) 'Open document
wrdDoc.SaveAs FileName:=strDocToSave, FileFormat:=wdFormatTextLineBreaks
wrdDoc.Close SaveChanges:=False 'Close the document
Set wrdDoc = Nothing 'Clear Memeory
wrdApp.WordBasic.DisableAutoMacros 0
wrdApp.Quit SaveChanges:=False 'Quit Word with no more saves
Set wrdApp = Nothing 'Clear Memory
Word manually and it has this feature so I am trying to call that from within
VB6. I have written the following code which works except the destination
file format is always Word's default. Apparently the "fileformat" function of
the SaveAs line has something wrong but I need help determining what the
problem is? Any help would be appreciated.
Dim wrdApp As Object
Dim wrdDoc As Object
Dim strDocToOpen As String
Dim strDocToSave As String
strDocToOpen = "C:\Documents and Settings\Ray Smith\Junk\HTML test.htm"
strDocToSave = "C:\Documents and Settings\Ray Smith\Junk\HTML test.txt"
Set wrdApp = CreateObject("Word.Application")
wrdApp.WordBasic.DisableAutoMacros 'Disable any Macros
Set wrdDoc = wrdApp.Documents.Open(strDocToOpen) 'Open document
wrdDoc.SaveAs FileName:=strDocToSave, FileFormat:=wdFormatTextLineBreaks
wrdDoc.Close SaveChanges:=False 'Close the document
Set wrdDoc = Nothing 'Clear Memeory
wrdApp.WordBasic.DisableAutoMacros 0
wrdApp.Quit SaveChanges:=False 'Quit Word with no more saves
Set wrdApp = Nothing 'Clear Memory