none
Read MS Word document and get HTML formatted string using VSTO C# RRS feed

  • Question

  • Hi all,

    I am developing VSTO application using c# and need to convert whole document text to HTML formatted text. My need is to get each sentence with HTML string like. Operation: If i write in document HJ Soft then get this word like <b><i>HJ Soft</i></b>. I also developed custom ribbon control for word document. Ribbon contains verify button when I press that button I want to get above operation. So, any buddy can help me? 



    • Edited by H J SOFT Tuesday, October 11, 2016 5:34 AM
    Tuesday, October 11, 2016 5:28 AM

Answers

  • Hello H J,

    You can use the SaveAs2 method of the Document class from the Word object model. It saves the specified document with a new name or format. Some of the arguments for this method correspond to the options in the Save As dialog box (File tab).

    Note, you can specify the format in which the document is saved. Can be any WdSaveFormat constant. I believe the wdFormatHTML constant is exactly what you are looking for. 

    Then you can read the HTML markup of the document in the file saved on the disk. 


    [custom.development]

    • Marked as answer by H J SOFT Tuesday, October 11, 2016 6:11 AM
    Tuesday, October 11, 2016 6:00 AM

All replies

  • Hello H J,

    You can use the SaveAs2 method of the Document class from the Word object model. It saves the specified document with a new name or format. Some of the arguments for this method correspond to the options in the Save As dialog box (File tab).

    Note, you can specify the format in which the document is saved. Can be any WdSaveFormat constant. I believe the wdFormatHTML constant is exactly what you are looking for. 

    Then you can read the HTML markup of the document in the file saved on the disk. 


    [custom.development]

    • Marked as answer by H J SOFT Tuesday, October 11, 2016 6:11 AM
    Tuesday, October 11, 2016 6:00 AM
  • Thanks Eugene Astafiev

    But I don't wan't to save that file with any format in my machine. I want to perform operation without saving that particular document. If you have any suggestion rest of above then tell me. Again thanks. 


    • Edited by H J SOFT Tuesday, October 11, 2016 6:30 AM
    Tuesday, October 11, 2016 6:11 AM