Word To Html in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to Convert Word to HTML.

private void button1_Click(object sender, EventArgs e)
{
    //Create word document
    Document document = new Document();
    document.LoadFromFile(@"..\..\..\..\..\..\Data\FindAndReplace.doc");

    //Save doc file.
    document.SaveToFile("Sample.html", FileFormat.Html);

    //Launching the MS Word file.
    WordDocViewer("Sample.html");
}

private void WordDocViewer(string fileName)
{
    try
    {
        System.Diagnostics.Process.Start(fileName);
    }
    catch { }
}

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
	'Create word document
	Dim document_Renamed As New Document()
	document_Renamed.LoadFromFile("..\..\..\..\..\..\Data\FindAndReplace.doc")

	'Save doc file.
	document_Renamed.SaveToFile("Sample.html", FileFormat.Html)

	'Launching the MS Word file.
	WordDocViewer("Sample.html")
End Sub

Private Sub WordDocViewer(ByVal fileName As String)
	Try
		Process.Start(fileName)
	Catch
	End Try
End Sub