Exporting to Word - Set to Print Layout

Tips submitted by ASPMaker users

Exporting to Word - Set to Print Layout

Postby JW » Mon May 28, 2007 11:40 pm

Hello,
I have been battling with this issue for some time and finally hacked together some code that will do exactly what I needed. The following code needs to be in the top of the ASPM file that is being exported. What this does is set the margins to specific sizes (can be changed in the Style) and opens the word document to Print Layout instead of Web Layout. This too can be changed in the code below. Hope this helps someone.

<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>90</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<![endif]-->
</head>

Other View Element Values
* MasterPages
* Normal
* Print
* Web (default)




The Styles - Needed to specify the page margins.


<style>

<!--
/* Font Definitions */
@font-face
{font-family:Batang;
panose-1:2 3 6 0 0 1 1 1 1 1;
mso-font-alt:\BC14\D0D5;
mso-font-charset:129;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
@font-face
{font-family:"\@Batang";
panose-1:2 3 6 0 0 1 1 1 1 1;
mso-font-charset:129;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-print;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-fareast-language:EN-US;}
h1
{mso-style-next:Normal;
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-print;
page-break-after:avoid;
mso-outline-level:1;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:Batang;
mso-font-kerning:0pt;
mso-fareast-language:EN-US;
mso-bidi-font-weight:normal;}
h2
{mso-style-next:Normal;
margin:0in;
margin-bottom:.0001pt;
text-align:center;
mso-pagination:widow-print;
page-break-after:avoid;
mso-outline-level:2;
font-size:16.0pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:Batang;
mso-fareast-language:EN-US;
font-weight:normal;}
h3
{mso-style-next:Normal;
margin:0in;
margin-bottom:.0001pt;
text-align:center;
mso-pagination:widow-print;
page-break-after:avoid;
mso-outline-level:3;
font-size:16.0pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
color:green;
mso-fareast-language:EN-US;
font-weight:normal;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
{margin:0in;
margin-bottom:.0001pt;
text-align:center;
mso-pagination:widow-print;
font-size:14.0pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:Batang;
mso-fareast-language:EN-US;}
p.MsoBodyText2, li.MsoBodyText2, div.MsoBodyText2
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-print;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
color:green;
mso-fareast-language:EN-US;}
p.MsoBodyText3, li.MsoBodyText3, div.MsoBodyText3
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-print;
font-size:11.0pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
color:black;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:.6in .5in 33.1pt .5in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-page-numbers:1;
mso-paper-source:0;}
div.Section1
{page:Section1;}
@page Section2
{size:8.5in 11.0in;
margin:.6in .5in 33.1pt .5in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section2
{page:Section2;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-print;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->


Not all of this code is necessary, you can play with it to make it do what you need it to.

Good luck,
JW
JW
 

Re: Exporting to Word - Set to Print Layout

Postby bla bla » Tue Mar 03, 2009 2:06 am

thanks !!!
bla bla
 

Re: Exporting to Word - Set to Print Layout

Postby Pooja » Wed Sep 12, 2012 5:52 am

Thank you so much, tis was literally driving me mad. You saved my life today.....
Pooja
 


Return to User Submitted Tips (ASPMaker)