I need to pre-format an MS page. Particularly fonts so that they are consistent with a website. MS seems to ignore at the very least the font-family MSO styles set.
I have already tried !important
and saving the word document as a web page, editing styles and using those in the original HTML file I'm trying to format on the word page.
My code:
<style>
h1 {
font-family:'Trebuchet MS', Arial, sans-serif!important;
mso-fareast-font-family:"Trebuchet MS"!important;
}
p {
font-family:"Arial",Helvetica,sans-serif!important;
mso-fareast-font-family:"Arial"!important;
}
</style>
<%
Dim file
file = "saveddocument.doc"
With Response
.Buffer = True
.ContentType = "application/msword"
.AddHeader "content-disposition", "inline; filename=" & file
.Write "<h1>This text should be formatted as Trebuchet MS</h1>" _
& "<p> This text should be formatted as Arial</p>"
.Flush
.End
End With
%>
Expected Results:
When MS Word is opened the
h1
headings should be styled with the font Trebuchet MS and thep
tags with Arial.
Current result:
Defaulting to Times New Roman
What am I missing? Any help is much appreciated.
The answer to this for me goes as follows:
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=HelpFile.doc"
Response.write("<html " & _
"xmlns:o='urn:schemas-microsoft-com:office:office' " & _
"xmlns:w='urn:schemas-microsoft-com:office:word'" & _
"xmlns='https://www.w3.org/TR/html401/'>")
The xmlns
code in particular was missing from my code and thus was unable to read the css
.
Adding this into the document ensured that it was readable and fixed my font formatting issues. I hope this answer can help others in a similar situation in the future.