Word Automation

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

    #1

    Word Automation

    I am trying to do the following from an ASP.NET Web Application (C#).

    User fills out a form.
    The program takes those answers and merges them with a WORD document.

    I have tried the few examples of launching word from my app and get ACCESS
    DENIED when the Word attempts to start.

    Once the merge is complete, the document gets saved and sent to the user to
    open and further edit if necessary. The initial merge part doesn't have to
    even show up on the screen.

    If I can't automate Word to the merge, I can save my template files as RTF,
    but haven't found an easy way to read the RTF file and do that merge.

    Any help would be great. Thanks.

    ANDY
  • New

    #2
    Re: Word Automation

    I just wrote an app that had to do basically the same thing. Our requirement
    was to have the web app send an e-mail with an attached word doc. What I
    ended up doing was having my application write out the contents of the doc
    as html. The doc was an html page saved with a .doc extension. Word handles
    html natively, so when the person opens the .doc, they have no idea that
    it's not actually a true word document. This was fast and works perfectly.

    One last thing... I wrote the merge doc in Word and saved it as html to see
    what kind of funky tags word would add to the html and went with that.

    hth,
    Mike
    "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
    news:5AE7F5AD-0BA6-4123-92D0-92B3F6E30BE8@mi crosoft.com...[color=blue]
    >I am trying to do the following from an ASP.NET Web Application (C#).
    >
    > User fills out a form.
    > The program takes those answers and merges them with a WORD document.
    >
    > I have tried the few examples of launching word from my app and get ACCESS
    > DENIED when the Word attempts to start.
    >
    > Once the merge is complete, the document gets saved and sent to the user
    > to
    > open and further edit if necessary. The initial merge part doesn't have
    > to
    > even show up on the screen.
    >
    > If I can't automate Word to the merge, I can save my template files as
    > RTF,
    > but haven't found an easy way to read the RTF file and do that merge.
    >
    > Any help would be great. Thanks.
    >
    > ANDY[/color]


    Comment

    • Andy

      #3
      Re: Word Automation

      How can I do that?

      I can save my Template document as HTML, but how can I do the actual Merge
      without opening WORD and running MailMerge?


      "New" wrote:
      [color=blue]
      > I just wrote an app that had to do basically the same thing. Our requirement
      > was to have the web app send an e-mail with an attached word doc. What I
      > ended up doing was having my application write out the contents of the doc
      > as html. The doc was an html page saved with a .doc extension. Word handles
      > html natively, so when the person opens the .doc, they have no idea that
      > it's not actually a true word document. This was fast and works perfectly.
      >
      > One last thing... I wrote the merge doc in Word and saved it as html to see
      > what kind of funky tags word would add to the html and went with that.
      >
      > hth,
      > Mike
      > "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
      > news:5AE7F5AD-0BA6-4123-92D0-92B3F6E30BE8@mi crosoft.com...[color=green]
      > >I am trying to do the following from an ASP.NET Web Application (C#).
      > >
      > > User fills out a form.
      > > The program takes those answers and merges them with a WORD document.
      > >
      > > I have tried the few examples of launching word from my app and get ACCESS
      > > DENIED when the Word attempts to start.
      > >
      > > Once the merge is complete, the document gets saved and sent to the user
      > > to
      > > open and further edit if necessary. The initial merge part doesn't have
      > > to
      > > even show up on the screen.
      > >
      > > If I can't automate Word to the merge, I can save my template files as
      > > RTF,
      > > but haven't found an easy way to read the RTF file and do that merge.
      > >
      > > Any help would be great. Thanks.
      > >
      > > ANDY[/color]
      >
      >
      >[/color]

      Comment

      • New

        #4
        Re: Word Automation

        You can use streamwriter.wr iteline to append text to the file. Most of the
        writing will be static html. Whenever you need to insert a merge field,
        you'll grab the data from the form that the user has filled out. You're
        simply concatenating canned text with textbox items. The "word" document
        doesn't really exist until the user fills out the form and hits "submit." A
        typical merge scenario has an existing word doc and then does a merge with a
        data source. You can bypass all that by generating the html content
        dynamically. You could have the ASP.NET page save the file and e-mail it to
        the user for further modification.

        I hope I'm understanding you correctly.

        -Mike
        "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
        news:329E2D56-6DA7-4287-BF11-8C40A849F501@mi crosoft.com...[color=blue]
        > How can I do that?
        >
        > I can save my Template document as HTML, but how can I do the actual Merge
        > without opening WORD and running MailMerge?
        >
        >
        > "New" wrote:
        >[color=green]
        >> I just wrote an app that had to do basically the same thing. Our
        >> requirement
        >> was to have the web app send an e-mail with an attached word doc. What I
        >> ended up doing was having my application write out the contents of the
        >> doc
        >> as html. The doc was an html page saved with a .doc extension. Word
        >> handles
        >> html natively, so when the person opens the .doc, they have no idea that
        >> it's not actually a true word document. This was fast and works
        >> perfectly.
        >>
        >> One last thing... I wrote the merge doc in Word and saved it as html to
        >> see
        >> what kind of funky tags word would add to the html and went with that.
        >>
        >> hth,
        >> Mike
        >> "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
        >> news:5AE7F5AD-0BA6-4123-92D0-92B3F6E30BE8@mi crosoft.com...[color=darkred]
        >> >I am trying to do the following from an ASP.NET Web Application (C#).
        >> >
        >> > User fills out a form.
        >> > The program takes those answers and merges them with a WORD document.
        >> >
        >> > I have tried the few examples of launching word from my app and get
        >> > ACCESS
        >> > DENIED when the Word attempts to start.
        >> >
        >> > Once the merge is complete, the document gets saved and sent to the
        >> > user
        >> > to
        >> > open and further edit if necessary. The initial merge part doesn't
        >> > have
        >> > to
        >> > even show up on the screen.
        >> >
        >> > If I can't automate Word to the merge, I can save my template files as
        >> > RTF,
        >> > but haven't found an easy way to read the RTF file and do that merge.
        >> >
        >> > Any help would be great. Thanks.
        >> >
        >> > ANDY[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        Working...