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

[182 byte] By [Rajeshbatchu] at [2007-12-24]
# 1

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

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

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

it is showing an exception of file format not valid

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

Rajeshbatchu at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
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
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
this is not working
Rajeshbatchu at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5

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.

spotty at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6

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)

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7

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

Rajeshbatchu at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8
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
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9

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!

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10
Dman - re read my passage please - regardless the "extension" you save it - it has to be an RTF format
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 11

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.

cgraus at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 12

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

Karrar at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...