locked
Rich Text Display Only. RRS feed

  • Question

  • User1716674006 posted

    Hi,

    I have a code which loads WORD document

    Sub Read(ByVal RPath As String)

    If RPath <> "" Then

    Dim WordApp As New Word.ApplicationClass

    Dim filepath = Server.MapPath("Uploaded\") & RPath

    Dim File As Object = filepath

    Dim nullobj As Object = System.Reflection.Missing.Value

    Dim doc As Word.Document = WordApp.Documents.Open(File, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj)

    Dim doc1 As Word.Document = WordApp.ActiveDocument

    Dim m_Content As String = doc1.Content.Text

    TextBox1.Text = m_Content

    doc.Close(nullobj, nullobj, nullobj)

    End If

    End Sub

     

    But This code loads only Text to the Textbox1.text without formatting.

    I need to modify this script so that  I can display the contents on a RICHTEXTBOX

    thanks in advance

     

    Tuesday, January 6, 2009 11:45 AM

Answers

  • User-504499122 posted

     Hi,

    The native asp.net textbox does not provide you with rich textbox features. 

    There is a RichTextBox in Windows forms, but if you want the same functionality in asp.net you might have to use a third party control for that

    http://www.richtextbox.com/cs/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 12:03 PM
  • User-1136466523 posted

    Hi,

    I think you need to use a ASP.NET richtextbox to display your rich text, otherwise, you can achieve that.

    Following is an article which shares some information on how to create richtextbox,.

    http://aspnet.4guysfromrolla.com/articles/102004-1.aspx

    Here are the codes for you to retrieve the text from word document.


    Dim Oword As Object
    Dim Odoc As Object

    Private Sub Command1_Click()
      Set Oword = CreateObject("Word.Application")
      Set Odoc = Oword.documents.open("C:\temp.doc")
      Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
      Oword.quit
    Me.RichTextBox1 = ""
      Me.RichTextBox1.FileName = "C:\x.rtf"
    End SubDim Oword As Object
    Dim Odoc As Object

    Private Sub Command1_Click()
      Set Oword = CreateObject("Word.Application")
      Set Odoc = Oword.documents.open("C:\temp.doc")
      Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
      Oword.quit
    Me.RichTextBox1 = ""
      Me.RichTextBox1.FileName = "C:\x.rtf" // RichTextBox1 is the instance name of richtextbox.
    End Sub

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 11, 2009 11:49 PM

All replies

  • User-504499122 posted

     Hi,

    The native asp.net textbox does not provide you with rich textbox features. 

    There is a RichTextBox in Windows forms, but if you want the same functionality in asp.net you might have to use a third party control for that

    http://www.richtextbox.com/cs/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 12:03 PM
  • User1716674006 posted

    Dim doc1 As Word.Document = WordApp.ActiveDocument

    Dim m_Content As String = doc1.Content.Text

     

    extracts only text, how can the entire richtext??

     

    thanks

    Wednesday, January 7, 2009 4:59 AM
  • User-1136466523 posted

    Hi,

    I think you need to use a ASP.NET richtextbox to display your rich text, otherwise, you can achieve that.

    Following is an article which shares some information on how to create richtextbox,.

    http://aspnet.4guysfromrolla.com/articles/102004-1.aspx

    Here are the codes for you to retrieve the text from word document.


    Dim Oword As Object
    Dim Odoc As Object

    Private Sub Command1_Click()
      Set Oword = CreateObject("Word.Application")
      Set Odoc = Oword.documents.open("C:\temp.doc")
      Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
      Oword.quit
    Me.RichTextBox1 = ""
      Me.RichTextBox1.FileName = "C:\x.rtf"
    End SubDim Oword As Object
    Dim Odoc As Object

    Private Sub Command1_Click()
      Set Oword = CreateObject("Word.Application")
      Set Odoc = Oword.documents.open("C:\temp.doc")
      Odoc.SaveAs FileName:="c:\x.rtf", FileFormat:=6
      Oword.quit
    Me.RichTextBox1 = ""
      Me.RichTextBox1.FileName = "C:\x.rtf" // RichTextBox1 is the instance name of richtextbox.
    End Sub

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 11, 2009 11:49 PM