Thread: [Solved] HTML Class to Word Styles
View Single Post
 
Old 08-16-2023, 07:44 PM
Journeyman Journeyman is offline Windows 10 Office 2019
Novice
 
Join Date: Feb 2023
Posts: 15
Journeyman is on a distinguished road
Default HTML Class to Word Styles

Hi all,

Not so sure this belongs here, but some cluey person might have an answer.

I have an HTML file that is being imported into MS Word. e.g.

Code:
Set oDoc = oApp.documents.add
oDoc.Range.InsertFile = "C:MyPath\MyFile.htm"
This results in a word document being produced with the HTM output.

On that import, any text recognised as a Header (e.g. 'H1') is automatically applied to the Heading 1 style. Awesome... except...

...any other text is converted into the Normal style. So I tried to be clever and set the class of the HTML tag. e.g.

Code:
<p style='Font-Family:Tahoma,Geneva, sans-serif' Class='Body Text">My Paragraph</p>
So the document is imported into word.... but a new style called 'body' (lowercase) is applied to the text. It seems to omit the full 'Body Text' class that I aimed for.

So... how might I address this problem?
Reply With Quote