P
Petr Danes
Does anyone have any experience with loading a document -INTO-Word using
HTML and a cascading style sheet? All the stuff I have found in the archives
deals with exporting Word docs to HTML - I want to do the opposite.
I have an ACCESS database that does lookups and uses VBA to create a Word
document detailing the results. Initially, I had the database using a Word
template to create the document, but the process was too slow to be useful,
so I converted it to write out plain text HTML, with references to a
cascading style sheet. The results are mixed. Speed is much improved, but
Word's use of the styles I define in the CSS are hit and miss. A sample few
lines of the generated HTML text and the entire style sheet are reproduced
at the end of this post.
The basic definition, the first style, named QuarxZakladOdstavec does not
appear at all in the created Word document, unless I add some unnecessary
text specifically using that style. The subsequent definitions, which I
would like to be based on this first one are not, but are based on Normal.
Some of the graphic definitions, specifically margins, seem to be ignored
completely. The styles are affected by whatever styles are already present
in Word, in fact, they seem to take precedence over those defined in the CSS
file, and I have to run some VBA code which deletes all 'Quarx' styles
before some changes take effect. (But not all, some CSS styles do take
effect next time the HTML file is loaded, even if the old style remains.)
The Access code opens a Word template, which uses this line to load the HTML
file:
doc.Range.InsertFile FileName:="abc.htm"
if that makes any difference.
Word is capable of creating this stuff from its native files as well as
reading files in this and other formats, but my results seem almost random.
If anyone can shed some light on this, or maybe even suggest a different
approach altogether, I'd appreciate some thoughts.
Pete
=====================================================
Beginning of generated HTML text file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
<head>
<title>Class and ID Selectors</title>
<meta http-equiv="Content-Type"
content="text/xhtml;charset=windows-1250"/>
<link rel='stylesheet' type='text/css' href='C:\Users\Petr
Danes\AppData\Local\Temp\QuarxStylesheet 2008-12-16_14-29-12.css'/>
</head>
<body >
<p class='QuarxZakladOdstavec'>
ABCEDFG
<p class='QuarxHS'>
.._HS Gottaischer [C:\Palma\T602\Hyper\A test\BATEL\BATELOV.TXT] {001}
</p>
<p class='QuarxPovel'>
..AU
</p>
<p class='QuarxAutor'>
Gottaischer
</p>
<p class='QuarxPovel'>
..TI
</p>
<p class='QuarxObycejnyText'>
Gottaischer Hofkalender fuer 1779, 1780.
</p>
<p class='QuarxPovel'>
..IM
</p>
<p class='QuarxObycejnyText'>
Goth a, s. t., 1779, 1780, 110, 175 s., 8´.
</p>
<p class='QuarxPovel'>
..RO
</p>
<p class='QuarxObycejnyText'>
</p>
<p class='QuarxPovel'>
<!--
Entire CSS file
/* Style Definitions */
/* Tohle je základ pro v¹echny dal¹í styly, pou¾ité pro rùzná oznaèení */
p.QuarxZakladOdstavec
{mso-style-name:QuarxZakladOdstavec;
mso-style-parent:"Normal";
mso-pagination:widow-orphan;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
font-family:"Courier New";}
/* Autor, signatura a datum jsou speciálnì oznaèené, aby byly rychle vidìt
*/
p.QuarxAutor
{mso-style-name:QuarxAutor;
mso-style-parent:QuarxZakladOdstavec;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:red;
font-weight:bold;}
p.QuarxSignatura
{mso-style-name:QuarxSignatura;
mso-style-parent:QuarxZakladOdstavec;
color:blue;
font-weight:bold;}
p.QuarxDatum
{mso-style-name:QuarxDatum;
mso-style-parent:QuarxZakladOdstavec;
color:#44BB44;
font-weight:bold;
text-decoration:underline;
text-underline:single;}
p.QuarxProvenience
{mso-style-name:QuarxProvenience;
mso-style-parent:QuarxZakladOdstavec;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
font-weight:bold;}
/* Záhlaví, oznaèené pomocí ._HS, je barvené podle toho, jestli heslo
obsahuje nebo neobsahuje hledaný text */
p.QuarxHS
{mso-style-name:QuarxHS;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxZakladOdstavec;
page-break-before:always;
mso-border-top-alt:solid black 0.5pt;
tab-stops:right 468.0pt;
font-size:8.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:#999999;}
/* Teèkové povely jsou oznaèené tady */
p.QuarxPovel
{mso-style-name:QuarxPovel;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxZakladOdstavec;
font-size:8.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:#33CCCC;
display:none;
mso-hide:all;}
/* Teèkové povely jsou oznaèené tady */
p.QuarxObycejnyText
{mso-style-name:QuarxObycejnyText;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxPovel;
font-size:12.0pt;
margin-top:0pt;
margin-right:0pt;
margin-left:1.0cm;
margin-bottom:0pt;
font-family:"Courier New";}
/* Tady je speciální oznaèení nalezeného textu */
span.QuarxFound
{mso-style-name:QuarxFound;
backgroundink;}
span.QuarxNalezenyText
{mso-style-name:QuarxNalezenyText;
background:yellow;
border:1px solid lime;}
--
This e-mail address is fake, to keep spammers and their address harvesters
out
of my hair. If you want to get in touch personally, I am 'pdanes' and I use
yahoo mail. But please use the newsgroup when possible, so that all may
benefit from the exchange of ideas.
HTML and a cascading style sheet? All the stuff I have found in the archives
deals with exporting Word docs to HTML - I want to do the opposite.
I have an ACCESS database that does lookups and uses VBA to create a Word
document detailing the results. Initially, I had the database using a Word
template to create the document, but the process was too slow to be useful,
so I converted it to write out plain text HTML, with references to a
cascading style sheet. The results are mixed. Speed is much improved, but
Word's use of the styles I define in the CSS are hit and miss. A sample few
lines of the generated HTML text and the entire style sheet are reproduced
at the end of this post.
The basic definition, the first style, named QuarxZakladOdstavec does not
appear at all in the created Word document, unless I add some unnecessary
text specifically using that style. The subsequent definitions, which I
would like to be based on this first one are not, but are based on Normal.
Some of the graphic definitions, specifically margins, seem to be ignored
completely. The styles are affected by whatever styles are already present
in Word, in fact, they seem to take precedence over those defined in the CSS
file, and I have to run some VBA code which deletes all 'Quarx' styles
before some changes take effect. (But not all, some CSS styles do take
effect next time the HTML file is loaded, even if the old style remains.)
The Access code opens a Word template, which uses this line to load the HTML
file:
doc.Range.InsertFile FileName:="abc.htm"
if that makes any difference.
Word is capable of creating this stuff from its native files as well as
reading files in this and other formats, but my results seem almost random.
If anyone can shed some light on this, or maybe even suggest a different
approach altogether, I'd appreciate some thoughts.
Pete
=====================================================
Beginning of generated HTML text file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
<head>
<title>Class and ID Selectors</title>
<meta http-equiv="Content-Type"
content="text/xhtml;charset=windows-1250"/>
<link rel='stylesheet' type='text/css' href='C:\Users\Petr
Danes\AppData\Local\Temp\QuarxStylesheet 2008-12-16_14-29-12.css'/>
</head>
<body >
<p class='QuarxZakladOdstavec'>
ABCEDFG
<p class='QuarxHS'>
.._HS Gottaischer [C:\Palma\T602\Hyper\A test\BATEL\BATELOV.TXT] {001}
</p>
<p class='QuarxPovel'>
..AU
</p>
<p class='QuarxAutor'>
Gottaischer
</p>
<p class='QuarxPovel'>
..TI
</p>
<p class='QuarxObycejnyText'>
Gottaischer Hofkalender fuer 1779, 1780.
</p>
<p class='QuarxPovel'>
..IM
</p>
<p class='QuarxObycejnyText'>
Goth a, s. t., 1779, 1780, 110, 175 s., 8´.
</p>
<p class='QuarxPovel'>
..RO
</p>
<p class='QuarxObycejnyText'>
</p>
<p class='QuarxPovel'>
<!--
Entire CSS file
/* Style Definitions */
/* Tohle je základ pro v¹echny dal¹í styly, pou¾ité pro rùzná oznaèení */
p.QuarxZakladOdstavec
{mso-style-name:QuarxZakladOdstavec;
mso-style-parent:"Normal";
mso-pagination:widow-orphan;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
font-family:"Courier New";}
/* Autor, signatura a datum jsou speciálnì oznaèené, aby byly rychle vidìt
*/
p.QuarxAutor
{mso-style-name:QuarxAutor;
mso-style-parent:QuarxZakladOdstavec;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:red;
font-weight:bold;}
p.QuarxSignatura
{mso-style-name:QuarxSignatura;
mso-style-parent:QuarxZakladOdstavec;
color:blue;
font-weight:bold;}
p.QuarxDatum
{mso-style-name:QuarxDatum;
mso-style-parent:QuarxZakladOdstavec;
color:#44BB44;
font-weight:bold;
text-decoration:underline;
text-underline:single;}
p.QuarxProvenience
{mso-style-name:QuarxProvenience;
mso-style-parent:QuarxZakladOdstavec;
font-size:12.0pt;
margin-top:0pt;
margin-bottom:0pt;
font-weight:bold;}
/* Záhlaví, oznaèené pomocí ._HS, je barvené podle toho, jestli heslo
obsahuje nebo neobsahuje hledaný text */
p.QuarxHS
{mso-style-name:QuarxHS;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxZakladOdstavec;
page-break-before:always;
mso-border-top-alt:solid black 0.5pt;
tab-stops:right 468.0pt;
font-size:8.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:#999999;}
/* Teèkové povely jsou oznaèené tady */
p.QuarxPovel
{mso-style-name:QuarxPovel;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxZakladOdstavec;
font-size:8.0pt;
margin-top:0pt;
margin-bottom:0pt;
color:#33CCCC;
display:none;
mso-hide:all;}
/* Teèkové povely jsou oznaèené tady */
p.QuarxObycejnyText
{mso-style-name:QuarxObycejnyText;
mso-style-parent:QuarxZakladOdstavec;
mso-style-next:QuarxPovel;
font-size:12.0pt;
margin-top:0pt;
margin-right:0pt;
margin-left:1.0cm;
margin-bottom:0pt;
font-family:"Courier New";}
/* Tady je speciální oznaèení nalezeného textu */
span.QuarxFound
{mso-style-name:QuarxFound;
backgroundink;}
span.QuarxNalezenyText
{mso-style-name:QuarxNalezenyText;
background:yellow;
border:1px solid lime;}
--
This e-mail address is fake, to keep spammers and their address harvesters
out
of my hair. If you want to get in touch personally, I am 'pdanes' and I use
yahoo mail. But please use the newsgroup when possible, so that all may
benefit from the exchange of ideas.