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

Convert Word DOC DOCX to HTML MHTML

You can easily convert Word documents (DOC/DOCX) to web pages like HTML or MHTML format. Aspose.Words for .NET API can be used to perform this conversion using C# or VB.NET. Conversion of Microsoft Word documents is a popular use case so different options are supported by the API for the conversion. Let us take a look at the headings we will be covering here:

Word (DOC/DOCX) 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 Webpage Programmatically with C# VB.NET

You can efficiently convert a word document (DOC/DOCX) to 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# VB.NET

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 without needing to install Microsoft Word application. You can perform the conversions programmatically in your .NET applications based on C# or VB.NET programming languages. We have learned with examples and detailed steps as to how to make the API calls for exporting Word documents to your required file formats. You may also 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++