Use the HTMLToWord object to insert well-formed HTML (XHTML) text into a WordWriter Document object. You can specify a style to use when inserting text or use the document's default style. You can also specify whether to insert text after a specific element or at the end of a document.

 public class HTMLToWord
Public Class HTMLToWord

The contents of HTML tags not listed on the HTMLToWord Supported Tags may be inserted into the document as plain text. The behavior is dependent on the settings of the AcceptUnknownTags and IncludeContentsOfUnknownTags properties found in the HTMLInsertProperties property container.

For an overview of how to use the HTMLToWord object, see Using HTMLToWord.


//--- Well-formed HTML fragment to be inserted into the document.
string htmlFragment = @"<{span}{/span}p><{span}{/span}b>Hello,<{span}{/span}/b><{span}{/span}i> World<{span}{/span}/i>!<{span}{/span}/p>";


//--- Open an existing Word document with the SoftArtisans WordApplication object.
WordApplication wApp = new WordApplication();
Document doc = wApp.Open("myDoument.doc");

//--- Create the HTMLToWord object.
HTMLToWord h2w = new HTMLToWord();

//--- Insert the HTML fragment at the end of the document.
//--- Use the default style.
h2w.InsertHTML(htmlFragment, doc, null, doc);

'--- Well-formed HTML fragment to be inserted into the document.
Dim htmlFragment As String = "<{span}{/span}p><{span}{/span}b>Hello,<{span}{/span}/b><{span}{/span}i> World<{span}{/span}/i>!<{span}{/span}/p>"

'--- Open an existing Word document with the SoftArtisans WordApplication object.
Dim wApp As New WordApplication()
Dim doc As Document = wApp.Open("myDoument.doc")

'--- Create the HTMLToWord object.
Dim h2w As New HTMLToWord()

'--- Insert the HTML fragment at the end of the document.
'--- Use the default style.
h2w.InsertHTML(htmlFragment, doc, Nothing, doc)

Name

Description

FormatElementDelegate

GetImageDelegate

InsertElementDelegate

Name

Description

DebugLogLevel

FormatDelegate

ImageDelegate

InsertDelegate

InsertProperties

LogFileName

Name

Description

InsertHTML(String, Document, NamedStyle, Element)

InsertHTML(String, Document, Element)

InsertHTML(String, Document)

Name

Description

HTMLInsertProperties

HTMLTagAction

LoggingLevel