Word Automation

G

Guest

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
 
P

Patrick Steele [MVP]

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.

You might want to re-think your approach to using Word via OLE
Automation in a server environment:

"INFO: Considerations for Server-Side Automation of Office"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757
 
N

New

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
 
G

Guest

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?
 
N

New

You can use streamwriter.writeline 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top