Paste HTML into Word
I have found a suitable answer to this.
- By stylizing each HTML object in the source, Word will then apply styles if you "paste" with the option "Keep source formatting", most of the kinds of CSS will be converted into a Word style.
eg:
This will have the same formatting in HTML when you copy/paste to Word with "Keep Formatting" selected.
<h1 style="border:1px solid #CCC;font-size:1.5em">Title</h1>
Related videos on Youtube
Geekster
Updated on September 18, 2022Comments
-
Geekster over 1 year
I'm have a tough time getting my HTML that I am pasting into word to be converted to the proper styles I want.
My HTML includes:
dt
,dd
,h1
-h7
,p
,li
,ul
... etc.dt
anddd
are not working. Word thinks they are paragraphs and applies the "Normal" style to them.h1
-h7
work great.li
works great.What can I put into word so that when I paste in these
dt
&dd
they will select a proper style?EDIT: I certainly appreciate the responses received so far, however nobody has really answered this yet. I cannot decide what the export medium is for this job, as I am not the decision maker. The requirement is MS Word files. There will be headers and footers, page numbering and a table of contents to the project, but whenever I paste HTML into Word the same problem happens: certain tags are styled and others are ignored.
My guess is that this is a deficiency/bug in MS Word, so I will go ahead and open a ticket with Microsoft.
-
PeeHaa almost 12 yearsWhy would you do that? Word isn't meant for that. It tries to do it (HTML mail anyone) and fails miserably.
-
Sam almost 12 yearsMS Word is a definite no no for making html. Use a free program like notepad++
-
Remou almost 12 yearsWord will assign classes to styles. If you are trying to create a formatted Word document using HTML, this may help.
-
Admin almost 12 yearsRemou: so if there is a style in Word that has a class name that matches it should apply the style? This is hugely helpful if that's gonna work!
-
Diodeus - James MacFarlane almost 12 yearsIf you want a document containing HTML, use a PDF.
-
Remou almost 12 yearsGeekster, yes. See stackoverflow.com/questions/282531/…
-
asfallows almost 12 yearsHave you tried saving it as a .html file and then opening that file with Word? I just tried this on a file I have and it appeared to be formatted correctly. The file I used isn't heavily styled, though, so I don't know if you'll get the desired results all the time.
-