Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I have a windows form application. i need to load word document in to rich text box using open file dialog. but please help me.

thank you
Posted

You could try using the Micrsoft tools for office, but I don't know if they will convert a word doc to RTF ( of course, if htey do, a lot of formatting will be lost ). there are commercial Word editor components you can buy.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Aug-12 2:36am    
You are right, but by saying "A" you could say "B": strictly speaking, one cannot. "Loading" with loss of information is not "loading", and loading into Word component is not loading into RichTextBox. So, formally, the answer is purely negative. (I voted "4".)
--SA
Christian Graus 2-Aug-12 2:48am    
Well, that is true. I often try to move past what is asked, to answer what is intended. He clearly wants to edit a word doc, I doubt he NEEDS it to be in a rich text box.
VB
'add reference Microsoft Word 12.0 Object Library

'add imports
Imports System.Drawing
Imports System.Drawing.Image
Imports System.IO
Imports Microsoft.Office.Interop
Imports Word = Microsoft.Office.Interop.Word
Imports System.Runtime.InteropServices

'add richtextbox rtbDoc
'add button and include 

 Dim wd As New Word.Application

                With wd
                    .Documents.Open(OpenFileDialog1.FileName)
                    .Selection.WholeStory()
                    .Selection.Copy()

                    rtbDoc.Paste() 'RICHTEXTBOX

                    .Quit()
                End With
                wd = Nothing
 
Share this answer
 
Comments
Member 11557678 28-Mar-15 13:46pm    
solution 3 is very good it really works fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900