Convert ASP page to Microsoft Word document

Insert the following at the top of an ASP page to convert it to a Word document (Word 97+ required on client desktop). It uses Microsoft Word's HTML parser to generate the page.

JScript:
<%@LANGUAGE="JSCRIPT" CODEPAGE="1252"%>
<%
Response.ContentType = "application/msword";
Response.AddHeader("Content-Disposition","attachment;filename=filename.doc");
%>
VBScript:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition","attachment;filename=filename.doc"
%>

Note that only the text will be saved if you save the file to disk (i.e. images will not be downloaded and embedded into the document)

Comments

Popular posts from this blog

Select box manipulation with jQuery

iTextSharp: Generating a Basic PDF file (ASP.NET/C#)

Popup Window Countdown (JavaScript)