Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Merge Data To Word Doc (A2k)

    I have a query [qryClients] which holds names & address's of our clients.
    I want to send each client a standard letter.

    How can I merge each clients name and address onto the letter.
    ie, one record per letter.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merge Data To Word Doc (A2k)

    You can initiate the mail merge from Access or from Word.
    From Access: select the query in the database window, then select Tools | Office Links | Merge it with Microsoft Word.
    From Word: select Tools | Mail Merge...
    It is also possible to write code to automate it. See for example the MSKB article How to use automation to run Word 2000 mail merge from Access 2000.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merge Data To Word Doc (A2k)

    Thanks Hans

    I've looked at the Microsoft example, fails to connect, does my code look correct ?
    I have created (for testing) the MyMerge.doc and put it in root C:

    <pre>Function MergeIt()
    Dim objWord As Word.Document
    Set objWord = GetObject("C:MyMerge.doc", "Word.Document")
    ' Make Word visible.
    objWord.Application.Visible = True
    ' Set the mail merge data source as the Northwind database.
    objWord.MailMerge.OpenDataSource _
    Name:="Cocuments and SettingsAdministratorDesktopSW-Reporter.mdb", _
    LinkToSource:=True, _
    Connection:="QUERY qryClients", _
    SQLStatement:="SELECT * FROM [qryClients]"
    ' Execute the mail merge.
    objWord.MailMerge.Execute
    End Function</pre>


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merge Data To Word Doc (A2k)

    The code looks OK.

    If you have just written the code, you MUST close and reopen the database before trying it. When you modify the design of the database, you lock the database exclusively, so Word cannot get data from the query.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merge Data To Word Doc (A2k)

    Hans
    I must be missing something !
    Running the code opens (in the start bar) the MyMerge.doc and a doc called Letters2.doc which just hang there.
    I can expand (Maximise or restore) which just shows an empty doc and a flashing cursor as if waiting for something to happen.
    Ive restricted the query to 10 records for testing only ?

    I was expecting something to happen ie the data to show on the docs.

  6. #6
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Kenton, Delaware, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merge Data To Word Doc (A2k)

    I to have had my share of problems with using dynamic queries requiring user input and mail merge. My solution has been using a "make table query". The end user sets what criteria is needed on a front end form, makes the new data table then opens the word document. Word seems to like having a stable table to draw data from.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merge Data To Word Doc (A2k)

    Does MyMerge.doc contain merge fields? If not, you won't see any data.

  8. #8
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merge Data To Word Doc (A2k)

    merge fields?

    Hans

    I saw nothing in the code which refers to fields or field names, not sure of the next step ?

    Thanks Bill, once I've sorted this I'll change the query to a make table.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merge Data To Word Doc (A2k)

    Dave, I would start by creating a merge document in Word using Tools | Mail Merge...
    The Mail Merge helper will lead you through the necessary steps.
    Check that the merge works as expected, then save the merge document.
    If it is OK, you may not need code in Access at all. If you still prefer to use code, refer to the merge document you saved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •