Click to See Complete Forum and Search --> : How to read MS Word file to RTB and edit it and save it Or how to READ MS Word? The rtb control does


lindawqu
August 8th, 2001, 11:58 AM
How to read MS Word file to RTB and edit it and save it Or how to READ MS Word only? The rtb control doesn't seem to work. I am using VB 6.

Iouri
August 8th, 2001, 12:47 PM
'DO not forget to add reference to Word library

Dim WordApp As Word.Application
Dim Document As Object


Private Sub Command1_Click()'write
Set WordApp = CreateObject("Word.Application")
Set Document = Word.Documents.Add
' Place some text in the doc

Document.Range.InsertBefore RichTextBox1.Text & vbCrLf & vbCrLf

Document.SaveAs App.Path & "\TEST.DOC"
' Close Word with the Quit method on the
' Application object
Word.Application.Quit
' Release the object variable
Set WordApp = Nothing
End Sub


Private Sub Command2_Click()'read
Set WordApp = CreateObject("Word.Application")
Set Document = Word.Documents.Add
Word.Documents.Open App.Path & "\TEST.DOC"
RichTextBox1.Text = Word.ActiveDocument.Range
'Word.Documents.Open
Word.Application.Quit
' Release the object variable
Set WordApp = Nothing
End Sub


Private Sub Command3_Click()
Unload Me
End Sub











Iouri Boutchkine
iouri@hotsheet.com