How to view ms document (doc, docx) in richtextbox.

Hi,

Unless you have a reason to open it in a richtextbox you can open it directly like so:

Module Module1
    Sub Main()
    ' Open the file 'example.docx' at the current program's directory.
    ' It will appear in a new instance of word.
    Process.Start("example.docx")
    End Sub
End Module

when I used your codes I got error `

The system cannot find the file specified
 Sub Main()
        ' Open the file 'example.docx' at the current program's directory.
        ' It will appear in a new instance of word.
        Process.Start("D:\My CV\CV")
    End Sub


    Private Sub RichTextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.GotFocus
        Try
            Main()
        Catch err As Exception
            MsgBox(err.Message, MsgBoxStyle.Exclamation)
        End Try
    End Sub

`

Is your file named 'CV' or is it 'CV.docx'? You have to use the complete filename. The system uses the extension in the filename to determine which program to run.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.