in my richtext box i need to load a ms word document file content

in my rich text box control i need to load the msword document file

my word document file contain

but it is accepting onely a text file

can any one help me




Answer this question

in my richtext box i need to load a ms word document file content

  • Boulderdude

    Did you save you documents from works as rtf documents and NOT word doc files.

    If they are not rtf files they will not work in the RichTextbox control.


  • Benjamin Coats

    the RTB control will only load RTF files, not word documents - its a different format altogether for the RTB control. the RTB Control can load RichText documents or plaindocument/text

  • Neotech

    it is showing an exception of file format not valid

    and my doc file contains tables if u have any idea plz tell me



  • J Guy Davidson

    Dman - re read my passage please - regardless the "extension" you save it - it has to be an RTF format

  • AlexanderO

    ahmedilyas wrote:
    RTB Controls can only load RTF formats, not doc files regardless

    ahmed...if the word document file is saved in the specified format as I last indicated it will be saved with a doc extension AND an rtf compatible format...however you are correct in that it will not open a normal word document....I hope that is clear enough for you that you don't feel ot neccessary to correct my statment again!



  • Suresh .M.V

    thank you all for helping me

    but in my project i need to brouse for a .doc files and lode that file in the richtextbox control



  • Michael G. Emmons

    yes...use the scond parameter (filetype) when loading a doc/rtf file:

    Me.RichTextBox1.LoadFile("C:\MyDoc.doc", RichTextBoxStreamType.RichText)



  • BradDaBug

    Just to be clear here ( although this has already been said ) - the RTF control can read rich text format, NOT the Word format. You keep referring to .doc files, assuming you mean ANY Word document by this ( and that seems likely, not least because it explains why you're having trouble ), this does not work. There is no way to read a Word doc on a PC that doesn't have Word. If it does, you can use the interop assemblies to interact with Word.



  • Xcel

    this is not working

  • c.c.chai

    Hii

    'You Can Use this Sample it works With Me

    'Where OpenFile Is the name of OpenFileDialog

    'and rtbTopic is the name of RTB

    OpenFile.ShowDialog()

    Dim SR As New IO.StreamReader(OpenFile.FileName)

    rtbTopic.Text = SR.ReadToEnd

    OpenFile.Reset()

    'Note :and you can Refine the files showing in the Open File Dialog to Show the *.doc only files by the following Code Sample

    OpenFileDialog.DefaultExt = "Document Files(*.doc)"

    OpenFileDialog.Filter = "Document Files(*.doc)|*.doc|Text Files(*.txt)|*.txt|Rtf Files(*.rtf)|*.rtf|HTML Files(*.html)|*.html| AllFiles(*.*)|*.*"

    I hope my code is usefull to you

    Bye



  • Olivier Cueilliez

    If you save your word document as "Word 97-2003 & 6.0/95-RTF" it will save the file as an rtf file with a doc extension...this format will allow you to open the document in previous versions of word and in your rtb

    Me.RichTextBox1.LoadFile("C:\TheDoc.doc", RichTextBoxStreamType.RichText)



  • QiSheng

    as stated, it cannot be done. You could however use perhaps MS Word interop to get the text, then paste it into the richtextbox control however you may lose some features/layout etc... I'm not entirely sure. RTB Controls can only load RTF formats, not doc files regardless

  • in my richtext box i need to load a ms word document file content