Convert Word DOC or DOCX to HTML, MHTML in C# VB.NET

Convert Word DOC DOCX to HTML MHTML

This article covers how to convert Word documents (DOC/DOCX) to HTML or MHTML using C# or VB.NET. Aspose.Words for .NET API can be used to perform this conversion quite easily. Conversion of Microsoft Word documents is a popular use case so different options are supported by the API. You can take a look at the headings that are covered in this article:

C# Word to HTML or MHTML Converter API

Aspose.Words for .NET API is specially designed to work with Microsoft Word supported file formats. You can convert a DOCX or DOC file to HTML or MHTML file format by downloading the API from New Releases section, or by installing it from NuGet using the command below:

Install-Package Aspose.Words -Version 20.9.0

Convert Word DOC or DOCX to HTML in C#

You can efficiently convert a word document (DOC/DOCX) to an HTML webpage programmatically in .NET applications using C# or VB.NET. You need to follow the steps below for the conversion:

  1. Load input DOCX word document
  2. Initialize an instance of HtmlSaveOptions
  3. Save the output HTML file

The following code snippet follows these steps and shows how to convert DOC/DOCX to HTML using C# or VB.NET:

Convert Word DOC or DOCX to HTML with Round-trip Information in C#

Some additional information is saved during Word to HTML conversion. It is known as round-trip information and is useful for the scenarios where converted HTML file is again rendered as a word document. You can follow these steps to convert DOC/DOCX to HTML using C#:

  1. Load the input word document
  2. Set ExportRoundtripInformation to true
  3. Save the output HTML file

The code snippet below explains how to convert Word DOC/DOCX file to HTML with round-trip information using C# or VB.NET:

Convert Word DOC or DOCX to MHTML in C#

MHTML file format is worth mentioning when you need a single HTML file with embedded images and fonts. You can convert Word document (DOC/DOCX) to MHTML with the steps below:

  1. Load source DOC/DOCX file
  2. Set SaveFormat to MHTML

The code snippet below shows how to convert a word document (DOC/DOCX) to MHML using C# or VB.NET:

Conclusion

In this article, we have covered how to convert word documents to HTML or MHTML files in C# without needing to install the Microsoft Word application. Furthermore, you have learned with examples and detailed steps to make the API calls for exporting Word documents to your required file formats. Additionally, you may take a look at API references and Documentation. Moreover, you can write back to us and ask about anything on Free Support Forum.

See Also

Insert Table in Word Documents Programmatically using C++