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.
Printable View
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.
'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
[email protected]