Big problem using MailMerge. I did check some code on the internet but i must not understand it. In desparation i try this code from a book. It doesnt do it the way i would (Using the me.Recordset of a tabular form and passing each row of the recordset to word. Each row represent a tenant his address and the amount due. The code in the book instead of the recordset use a Query. It open a document in word but doesnt fill the letter.docx and there is a little window that keep asking to open a list of tables or views that i have in my application.
Private Sub cmdPublipostage_Click()
Dim oApp As Word.Application
Dim DOC As Word.Document
Dim DBName As String
Const DOCName = "Lettre.docx"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set DOC = oApp.Documents.Open(Application.CurrentProject.Path & "" & DOCName)
DBName = Application.CurrentDb.Name
With DOC.MailMerge
.OpenDataSource Name:=DBName, Connection:="QUERY ReqfrmPublipostage"
.Destination = wdSendToPrinter
.Execute
End With
Exit Sub
End Sub
Thanks for your help
Private Sub cmdPublipostage_Click()
Dim oApp As Word.Application
Dim DOC As Word.Document
Dim DBName As String
Const DOCName = "Lettre.docx"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set DOC = oApp.Documents.Open(Application.CurrentProject.Path & "" & DOCName)
DBName = Application.CurrentDb.Name
With DOC.MailMerge
.OpenDataSource Name:=DBName, Connection:="QUERY ReqfrmPublipostage"
.Destination = wdSendToPrinter
.Execute
End With
Exit Sub
End Sub
Thanks for your help