locked
Preserving the formatting of a .doc document RRS feed

  • Question

  • User-912599024 posted

    Hi friends!

    I am working on a site that provides the user to upload documents as .txt or .doc

    I got some help to fetch the contents of the word[.doc] file from the server. Here goes the code.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim wordapp As New Word.ApplicationClass
            Dim o_null As Object = System.Reflection.Missing.Value
            Dim o_true As Object = True
            Dim o_false As Object = True
            Dim o_filePath As Object = Server.MapPath("~/documents/Garbage collector.docx")
            Dim doc As Word.Document
            doc = wordapp.Documents.Open(o_filePath, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null, o_null)
            Dim str As String
            str = doc.Content.Text
            Label1.Text = str
            doc.Close(o_null, o_null, o_null)
            wordapp.Quit(o_null, o_null, o_null)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(wordapp)
        End Sub


    But it shows only raw document, i.e, without any formatting. I want that the formatting [linebreaks etc] be preserved. What should be the way to do it?

    Guidance please.

    Friday, January 1, 2010 4:39 PM

Answers

All replies