[dba-Tech] More on Word Automation

Bryan Carbonnell carbonnb at gmail.com
Fri May 11 07:59:10 CDT 2007


On 5/10/07, Susan Harkins <ssharkins at setel.com> wrote:
> I'm using the following procedure to copy Access data to a Word form -- it's
> incredible simple. I'm wondering if there's a way to use this process to
> fill multiple forms instead of using the merge feature?

There sure is.

All you need to do is use a recordset instead of Access Form fields.

Something along the lines of this air code:

Do While not rst.eof
    Set doc = appWord.Documents.Open("path\to\base\document.doc")
    with doc
        .FormFields("fldCustomerID").Result = rst.Field("CustomerID)
        .FormFields("fldCompanyName").Result = rst.Field("CustomerName)
'... etc

    end with
    ' Now here you can either save the doc with a new name,
    ' or just leave it open for the OP to deal with.
loop

That's pretty much all there is to it.

-- 
Bryan Carbonnell - carbonnb at gmail.com
Life's journey is not to arrive at the grave safely in a well
preserved body, but rather to skid in sideways, totally worn out,
shouting "What a great ride!"



More information about the dba-Tech mailing list