473,503 Members | 11,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Output to MS Word - Please Help

Hi Folks,

I am trying to output the content of my ASP page to an MS Word Document with
a specific page size (8.5x11) and margins (.25" all around). I have used
the Response.ContentType = "application/vnd.ms-word" - along with the
Response.AddHeader to force the download without any trouble.

However, because this method outputs html, I can't get it to format the
margins in the resulting word document. While I can use the "style" tags to
fake a margin by entering a negative number (style=Margin-Left : -.75in), it
doesn't really change the documents margins that need to be set for
printing. and I can't set the page size either.

So, I tried digging in to the "FileSystemObject" to create an RTF file.
This sort-of works, but fills the server up with files that need to be
manually deleted. Also, the browser has a problem refreshing when viewing
an rtf file that has been overwritten with new information.

Is there any better solution for generating on-the-fly Word Documents which
require detailed formatting of margins and page size?

Thanks very much,
Jack Coletti
St. Petersburg, FL


Jul 22 '05 #1
3 5536
"MostlyH2O" <jm*@takeitouthrmp.net> wrote in message
news:5t*******************@tornado.tampabay.rr.com ...
Hi Folks,

I am trying to output the content of my ASP page to an MS Word Document with a specific page size (8.5x11) and margins (.25" all around). I have used
the Response.ContentType = "application/vnd.ms-word" - along with the
Response.AddHeader to force the download without any trouble.

However, because this method outputs html, I can't get it to format the
margins in the resulting word document. While I can use the "style" tags to fake a margin by entering a negative number (style=Margin-Left : -.75in), it doesn't really change the documents margins that need to be set for
printing. and I can't set the page size either.

So, I tried digging in to the "FileSystemObject" to create an RTF file.
This sort-of works, but fills the server up with files that need to be
manually deleted. Also, the browser has a problem refreshing when viewing
an rtf file that has been overwritten with new information.

Is there any better solution for generating on-the-fly Word Documents which require detailed formatting of margins and page size?


Why not try the Word technique with rtf? The mime-type is just
application/rtf ...
Jul 22 '05 #2
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:e5*************@TK2MSFTNGP11.phx.gbl...
"MostlyH2O" <jm*@takeitouthrmp.net> wrote in message
news:5t*******************@tornado.tampabay.rr.com ...
Hi Folks,

I am trying to output the content of my ASP page to an MS Word Document with
a specific page size (8.5x11) and margins (.25" all around). I have used the Response.ContentType = "application/vnd.ms-word" - along with the
Response.AddHeader to force the download without any trouble.

However, because this method outputs html, I can't get it to format the
margins in the resulting word document. While I can use the "style"

tags to
fake a margin by entering a negative number (style=Margin-Left
: -.75in), it
doesn't really change the documents margins that need to be set for
printing. and I can't set the page size either.


Another approach - "try reverse engineering" the document. Set it up in
Word, then save the file as HTML and check out the resulting style code
that's created. In some tests I did, Word seems to save the print margin
and page size info.
Jul 22 '05 #3
> Another approach - "try reverse engineering" the document. Set it up in
Word, then save the file as HTML and check out the resulting style code
that's created. In some tests I did, Word seems to save the print margin
and page size info.


Hi Tom,

I ended up combining your 2 suggestions and got it to work. While reverse
engineering the html did set margins in the style, they were not retained in
the print layout view of word . So, I saved my document as an RTF and
opened it in notepad to get the RTF code. Then I pasted it into my asp page
and set the mime type. It works.

Thanks very much for your help. I really appreciate it :-)

Jack
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1621
by: David Goodyear | last post by:
At the moment im experimenting with ideas in C++ and would really like to solve the following, please please help. Sorry i dont even know what the subject is this would come under? :( Sorry if...
6
1577
by: Martin Hampl | last post by:
Hi, I am using PostgreSQL 7.4, but I did have the same problem with the last version. I indexed the column word (defined as varchar(64)) using lower(word). If I use the following query,...
8
3140
by: CM | last post by:
Hi, Could anyone please help me? I am completing my Master's Degree and need to reproduce a Webpage in Word. Aspects of the page are lost and some of the text goes. I would really appreciate it....
2
2114
by: Bsnpr8 | last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really...
3
1534
by: marsguy85 | last post by:
2 DAYS TO SUBMIT AND I COULD NOT GET MY HEAD AROUND TO DO IT , I HAVE BEEN STUDING VERY HARD FOR ALL SUBJECTS INCLUDING ANSI C BUT ITS HARD . PLEASE SAVE ME . GOD BLESS U. Hello friends i have to...
1
3982
by: iElf | last post by:
can someone point out my error? cus this is printing out garbage and not the longest word... Program ( I underlined the loop Im trying to make to read and find the longest word) everything else...
3
1951
NewYorker
by: NewYorker | last post by:
Hello brothers and sisters, Please help me complete this program and get the output shown below. Here is all I have ___________________________________________________________ This...
9
2481
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
0
1885
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.