CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2001
    Posts
    430

    How to read MS Word file to RTB and edit it and save it Or how to READ MS Word? The rtb control does

    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.



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: How to read MS Word file to RTB and edit it and save it Or how to READ MS Word? The rtb control

    '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]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured