none
Word add in Save word as HTML RRS feed

  • Question

  • I can save a WORD document as HTML (or Filtered HTML) as follows:

     myDoc.SaveAs2(FileName: myConvertedHTMLFile, FileFormat: Word.WdSaveFormat.wdFormatHTML);

    How can we achieve the same using ms office word add in?
    Friday, December 28, 2018 9:21 AM

Answers

  • Hi Nicholasmin,

    You can try the following code to save Word as HTML:

    var mammoth = require("mammoth");
    
    mammoth.convertToHtml({path: "path/to/document.docx"})
        .then(function(result){
            var html = result.value; // The generated HTML 
            var messages = result.messages; // Any messages, such as warnings during conversion 
        })
        .done();

    For more information, please review the following links:

    Is it possible to convert doc/docx to html using jquery/javascript?

    mammoth.js

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by Nicholasmin Thursday, January 3, 2019 11:04 AM
    Friday, December 28, 2018 9:41 AM
    Moderator
  • Hi Nicholasmin,

    Thanks for your asking. Did you resolve your issue? If the post helps you, you can mark it as answer and close the post.

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

    I wish you a happy life!

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by Nicholasmin Thursday, January 3, 2019 11:04 AM
    Wednesday, January 2, 2019 2:08 AM
    Moderator

All replies

  • Hi Nicholasmin,

    You can try the following code to save Word as HTML:

    var mammoth = require("mammoth");
    
    mammoth.convertToHtml({path: "path/to/document.docx"})
        .then(function(result){
            var html = result.value; // The generated HTML 
            var messages = result.messages; // Any messages, such as warnings during conversion 
        })
        .done();

    For more information, please review the following links:

    Is it possible to convert doc/docx to html using jquery/javascript?

    mammoth.js

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by Nicholasmin Thursday, January 3, 2019 11:04 AM
    Friday, December 28, 2018 9:41 AM
    Moderator
  • Hi Nicholasmin,

    Thanks for your asking. Did you resolve your issue? If the post helps you, you can mark it as answer and close the post.

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

    I wish you a happy life!

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by Nicholasmin Thursday, January 3, 2019 11:04 AM
    Wednesday, January 2, 2019 2:08 AM
    Moderator