Doc2Html2Doc Word Macro
Converts the current selection to an HTML string, or writes an HTML string into the document, preserving formatting.
Who might find this useful?
Word's Export as HTML function only exports the entire document as HTML, and the HTML it exports is (in)famous for its bloat and non-compliant style. If you only need to convert a fragment of the current document into HTML, or you want to produce cleaner HTML, then this macro will probably be useful to you.
If you are a VBA programmer, two functions allow you to convert to and from
Html2Doc. These are the core
of the functionality used by TransAssist to convert text segments between Word formatting
and the native HTML format used to store translation memories.
Download the Doc2Html2Doc macro file.
Launch Microsoft Word
Press Alt + F11
The Microsoft Visual Basic window appears.
From the File menu, select Import File...
Import the Doc2Html2Doc.bas file.
Close the Visual Basic window.
Press Alt + F8 to get the macro window, specify one of the following macros:
WriteSelectionAsHtml – The currently selected Word text fragment is written on the next line as HTML.
WriteSelectionAsDoc – The currently selected HTML text is written on the next line with Word formatting
Next, click Run.
If you will be using a macro more frequently, then you can assign it a keyboard shortcut. To do so,
Select Tools >> Customize
Set the "Categories" to Macros, and "Commands" to the macro you wish to assign
Select "Press new shortcut key," and press your keyboard shortcut.