How to read Word document online with formatting RRS feed

  • Question

  • User1833322396 posted


    I want to read a word document in my web application and display the word matter in a richtextarea with all the formatting.

    I have done this by converting a doc file into an HTML file.

    It is running fine on my system but giving following error while running on online.

    Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

    I have heard another method by using clipboard of web application.

    I used following code to get this.

    Microsoft.Office.Interop.Word.ApplicationClass newApp = new Microsoft.Office.Interop.Word.ApplicationClass();

    object file = path;
    object nullobj = System.Reflection.Missing.Value;
    Microsoft.Office.Interop.Word.Document doc = newApp.Documents.Open(
    ref file, ref nullobj, ref nullobj,
    ref nullobj, ref nullobj, ref nullobj,
    ref nullobj, ref nullobj, ref nullobj,
    ref nullobj, ref nullobj, ref nullobj);
    txtarea.Content = doc.Content.Text;

    But it is giving me only doc matter without formatting

    I want the doc matter with all formatting.

    Plz help me. 

    Also tell me if there is another way to solve this.


    Monday, January 23, 2012 3:04 PM


  • User-434868552 posted

    @ srivastava.sachin

    if the document is on your system, just convert it in advance to HTML ... that would be the simpliest solution.

    if the document is on the end user's system, have them first upload it to your system, then converted.

    do not depend on the end user allowing you to use her/his clipboard.

    from your code, it looks like the document is on your system.

    unless the Word document(s) is(are) dynamically modified by your end user(s), it's a waste of the end user's time imho to being doing online conversion.

    please describe what you are doiing and why in order to assist forums.asp.net members to better help you.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 23, 2012 3:16 PM