Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
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 1-Aug-12 21:23pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

'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
 
  Permalink  
Comments
Member 11557678 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 383
1 Sascha Lefévre 215
2 Maciej Los 185
3 Abhinav S 170
4 Richard Deeming 155
0 Sergey Alexandrovich Kryukov 7,156
1 OriginalGriff 6,410
2 Maciej Los 2,877
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100