Forum Moderators: open

Message Too Old, No Replies

Inserting data in a word document from asp

asp word document

         

justgattaknow

4:52 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



Hello;

I'm fairly new to asp and I am trying to find my way through combining asp code with a word document.

I have an existing word document and an SQL Server database. Through an asp page, how do I get data from the database inserted into specific places in the word document? I am able to bring up the word document in the word application in the browser, but then I do not know how to insert the data into the document.

Any help is greatly appreciated.

aspdaddy

2:52 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Couple of things to be aware of with this

asp is a server side language so if you automate word on the client, asp code cannot control it, if you automate word on the server then nobody sees it.

Having said that, the best way I have found to customise word docs on-the-fly , is to insert text strings into predefined bookmarks in a .dot template file - :


With ActiveDocument
.Bookmarks("bkAddress1").Range.InsertBefore objRS("Address1")
End With

For more info, look into the word object model on msdn

HTH

justgattaknow

4:26 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Thanks for your response. Now I know how to insert the data, but I do not know how to connect to the sqlServer database. I am using word 97 what should the code for my connection look like. My database name is PADKSCO and my table name is grain_table.

Thanks

snookie

4:42 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



hmmm....

you could just change the reponse.contentType of a standard HTML/ASP eg.

Response.ContentType = "application/vnd.ms-word"

might be worth reading up on that...

good luck