Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vXP - How to do a mail merge out of Access

Status
Not open for further replies.

JoseQuiervo

Programmer
Sep 25, 2002
57
US
I have the necessary query ready, and I can make it a "Make Table" for a merge purpose. But I would like a single button dump the data from that query/table into a Word doc. What is the easiest way to do this?

Thanks
-Jose
 
Hi
I use two methods of interacting with Word:
1. Output letters in HTML format from Access and then load this into Word with template file.
2. Link directly to Access from Word.
Both of these can be done on a button.
Is this what you mean?
 
and you don't have to make a table for the results to be available in word, a Word mail merge can have a query as its source.



Leslie
 
How do I automate the merge with word feature by simply clicking a button off the main form?
 

Hi
For example, this would create a mailmerge from scratch. I got it from recording a macro in Word, then pasting into Access. Full stops have to be added before each recorded line. You will also need to set a reference to the Word Object Library.
Code:
Private Sub cmdMailMerge_Click()
    Dim oApp As Object

    Set oApp = CreateObject("Word.Application")
    With oApp
        .Documents.Add Template:= _
        "C:\<Path to Template file>\Normal.dot" _
        , NewTemplate:=False, DocumentType:=0

        .ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
        .ActiveDocument.MailMerge.OpenDataSource Name:="C:\MailMerge.mdb" _
        , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
        Format:=wdOpenFormatAuto, Connection:="QUERY Contact#A", SQLStatement:= _
        "SELECT * FROM [Contact#A]", SQLStatement1:=""
    .ActiveDocument.MailMerge.EditMainDocument
    .ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
        "FirstName"

    End With
    oApp.Visible = True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top