Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

“application/msword” and page size 2

Status
Not open for further replies.

guitarzan

Programmer
Apr 22, 2003
2,236
US
I am writing an ASP program, and part of this program involves a mail-merge type feature to print a “Letter” (pre-fill name, address, and various other information). After the letter is generated and printed it will usually be discarded, although occasionally the user wants to save it in Word format.

The solution I have chosen (for now) is generating the letter in HTML and displaying it in the browser with Response.ContentType = "application/msword", at which time the user can edit the document if necessary, print it, and even save it as a .doc.

However, I need this file to print on legal size paper. I cannot get this application/msword file to display or print in legal size. On the client machine, I set the printer to default to Legal size, and I changed my normal.dot page setup to legal size. This works as expected… when I create a new word doc, it defaults to legal. When I print a web page, it prints legal. Everything displays/prints legal size EXCEPT for my HTML code with Response.ContentType = "application/msword".

Does anyone have any suggestions how to solve this problem?
Thanks!

- guitarzan
 
Creto, you were right, the free verion ScriptX seems to do the printing stuff that I have been unable to do (force landscape, delete ie headers/footers) so I can get away with just formatting an IE page rather than involving microsoft word.

The ContentType="application/msword" thing still bugs the heck out of me, but that's a battle for another day.
 
Good to hear. Thanks for the follow up and the star.
 
guitarzan,
Create yourself a Word document and set the page properties the way you want them.
Then save the document as an HTML file.
Now view the source of that file and you will see the style properties relevant to setting the page layout.
You can use these style properties in the document you generate and that will set them in the Word doc that you save.
I did this very same thing but with a LOT more formatting. Created the document on a web page and saved it as a Doc file.
 
Hmmmmm... I never thought of saving a word doc as html and checking the properties there!

That does exactly what I wanted. Good job, thanks theniteowl!
 
Glad it worked.
I pulled this trick when I was writing an HTA application that had to do some highly formatted data to export into Word. Saved me a LOT of trouble.


Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top