Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Location
    UK near Blackpool
    Posts
    18

    Unanswered: Access query to Word letters using code

    I have created a query that gathers information for producing a monthly letter run to customers. I have succesfully run mail merge from within access but would like to make the process simpler for operatives with a click of a button.

    How do I code an event to fire up word and produce a multipage single document as per the merge for approx 200 letters per month using this query as the sorce.

    Ineed the routine to run without any further input by reading each item line in the query until the end.

    Any help appreciated as I have been playing with various scode samples none of which seem to be specific to my problem.

  2. #2
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    This may not be exactly what you are looking for, but may spark some idears.

    '-----------------------------------------------------------------------------------
    Function MergeIt()
    ' This opens the form letter. The form letter will then open a copy of the database
    ' which will link to the qryYourQuery to feed the form letter.
    '-----------------------------------------------------------------------------------
    'DECLARATIONS

    Dim objWord As Word.Document
    Dim strPath As String

    'CODE

    On Error GoTo ErrorHandler
    strPath = "S:\My Location\Databases\"
    Set objWord = GetObject(strPath & "Cover Letter.doc", "Word.Document")

    'Make Word visible.

    objWord.Application.Visible = True

    'Execute the mail merge.
    objWord.MailMerge.Execute

    Exit_Sub:
    Exit Function
    ErrorHandler:
    MsgBox "Error in function: MergeIt()" & Chr(13) & _
    "MS Access" & Err.Number & ": " & Err.Description
    Resume Exit_Sub
    End Function


    John
    This is the day the Lord has made, I will rejoice and be glad in it.

Posting Permissions

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