I have a web page written in a web application to take data and submit it to
a database. Once the data is submitted, I want to copy those values from
either the initial web form or from the database and put them into a form I
have created in Word. I can get the data submitted to the database, and I
can open the Word document, but I cannot figure out how to get the data into
the Word form. This would be easy if it were another ASP, but I can't figure
out how to do it with a DOC.
I have tried to do it from the opener (the initial web page, which opens the
Word document) - it would find the bookmark and enter the appropriate value.
I have also tried to code the Word form directly to go get the data from the
database. I have not been succesful using either approach. Can I please get
a simple example of how this is done?
Thanks -Jeff
Doug Robbins - 16 Nov 2004 02:51 GMT
I would dump the data into document variables using
ActiveDocument.Variables("varname").Value = [data from webpage]
then to have it displayed in the document, you would use a { DOCVARIABLE
varname } field which you would already have in the document (or template)
and you use an
ActiveDocument.Fields.Update
command to update the fields so that they display the values assigned to the
variables.
If any of the data is to go into the headers or footers of the document, you
will need to access the .Range of each header or footer in the document and
update the fields in it using
For i = 1 to ActiveDocument.Sections.Count
ActiveDocument.Sections(i).headers(wdHeaderFooterPrimary).Range.Fields.Update
'repeat for each footer and headerfooter type
Next i
Alternatively, see the article "Access a database and insert into a Word
document the data that you find there" at:
http://word.mvps.org/FAQs/InterDev/GetDataFromDB.htm

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
>I have a web page written in a web application to take data and submit it
>to
[quoted text clipped - 19 lines]
>
> Thanks -Jeff