Output to MS Word - Please Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MostlyH2O

    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.Conten tType = "applicatio n/vnd.ms-word" - along with the
    Response.AddHea der 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 "FileSystemObje ct" 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




  • Tom Kaminski [MVP]

    #2
    Re: Output to MS Word - Please Help

    "MostlyH2O" <jmc@takeitouth rmp.net> wrote in message
    news:5tRmd.3659 3$8G4.34102@tor nado.tampabay.r r.com...[color=blue]
    > Hi Folks,
    >
    > I am trying to output the content of my ASP page to an MS Word Document[/color]
    with[color=blue]
    > a specific page size (8.5x11) and margins (.25" all around). I have used
    > the Response.Conten tType = "applicatio n/vnd.ms-word" - along with the
    > Response.AddHea der 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[/color]
    to[color=blue]
    > fake a margin by entering a negative number (style=Margin-Left : -.75in),[/color]
    it[color=blue]
    > 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 "FileSystemObje ct" 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[/color]
    which[color=blue]
    > require detailed formatting of margins and page size?[/color]

    Why not try the Word technique with rtf? The mime-type is just
    application/rtf ...


    Comment

    • Tom Kaminski [MVP]

      #3
      Re: Output to MS Word - Please Help

      "Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
      news:e59frQXzEH A.824@TK2MSFTNG P11.phx.gbl...[color=blue]
      > "MostlyH2O" <jmc@takeitouth rmp.net> wrote in message
      > news:5tRmd.3659 3$8G4.34102@tor nado.tampabay.r r.com...[color=green]
      > > Hi Folks,
      > >
      > > I am trying to output the content of my ASP page to an MS Word Document[/color]
      > with[color=green]
      > > a specific page size (8.5x11) and margins (.25" all around). I have[/color][/color]
      used[color=blue][color=green]
      > > the Response.Conten tType = "applicatio n/vnd.ms-word" - along with the
      > > Response.AddHea der 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"[/color][/color]
      tags[color=blue]
      > to[color=green]
      > > fake a margin by entering a negative number (style=Margin-Left[/color][/color]
      : -.75in),[color=blue]
      > it[color=green]
      > > doesn't really change the documents margins that need to be set for
      > > printing. and I can't set the page size either.[/color][/color]

      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.


      Comment

      • MostlyH2O

        #4
        Re: Output to MS Word - Please Help

        > Another approach - "try reverse engineering" the document. Set it up in[color=blue]
        > 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.[/color]

        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


        Comment

        Working...