How to import an html file into MS word, and have Word recognize the H tags?

Anonymous
2019-02-02T01:31:48+00:00

When you bring a simple HTML file into MS Word, (e.g. with H1 and H2 tags) Word will import it.

But it doesn't seem to fully recognize the H tags as "MS Word "headings"

Anyone know how to fix this?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2019-02-04T02:33:00+00:00

    If you open the HTML file in Google Docs and then, instead of copying and pasting into Word, you  go to File>Download as and select Microsoft Word (.docx) 

    and then open the downloaded document in Word, the appropriate Heading # styles will have been applied

    Less steps however if you simply paste the text with tags into Word and run the macro that I provided.

    1 person found this answer helpful.
    0 comments No comments

14 additional answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2019-02-02T23:10:57+00:00

    If I copy and paste that text into Word, and replace the H in my code with h, it assigns the Heading 1 and Heading 2 styles where appropriate.

    A coupe of further normal find and replaces are then required to remove the <p> and </p> tags

    This is the result

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-02-03T00:14:40+00:00

    That's true. 

    That would be one way to do it.

    But, then i would have to account for every HTML element.

    The way I got the text into MS Word was by opening the HTML file in Google Chrome, and then doing a COPY/PASTE into MS Word.

    If you do that, you'll see that Word won't consider the H1 tags has Heading 1. It makes them Normal Style. (Though, curiously, MS Word does build the tree hierarchy correctly.)

    my goal would be to run a macro and have MS Word assign the H tags correctly in this case.

    0 comments No comments
  3. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2019-02-03T01:26:58+00:00

    Send me a copy of the complete HTML file and I will see what can be done with it.

    0 comments No comments
  4. Anonymous
    2019-02-03T01:52:52+00:00

    They deleted my post last time i attached a file here.  Not sure why.

    But you can just copy the content here  http://snippi.com/s/3evb07n into a text file on your PC

    Then rename the txt file "example.html"

    then open it in chrome

    then copy/paste from chrome to ms word

    0 comments No comments