tomswaelen
Registered User.
- Local time
- Yesterday, 20:30
- Joined
- Nov 13, 2011
- Messages
- 10
Total VBA newbie here, but I've been able to piece together a code with varying degrees of help. I'm trying to make a button that uses a Word-document to perform a mail merge direct to the printer, and then close.
The code below opens the document that contains the mail merge data, but merges to a new document. What do I need to change?
The code below opens the document that contains the mail merge data, but merges to a new document. What do I need to change?
Code:
Private Sub Mail_merge_starten_Click()
Refresh
DoCmd.SetWarnings False
Dim WordApp As Object
Set WordApp = CreateObject("word.Application")
WordApp.Documents.Open "C:\Users\Tom\Desktop\Test\Resources\Opvragen officieel bewijs - NL.docm"
WordApp.Visible = True
With WordApp
.ActiveDocument.MailMerge.OpenDataSource _
Name:="C:\Users\Tom\Desktop\Test\Notarissen - opzoeken en opvolgen.accdb", _
LinkToSource:=True, Connection:="Opvraging - te versturen", _
SQLStatement:="SELECT * FROM [Opvraging - te versturen] WHERE Taal = ""N"""
.ActiveDocument.MailMerge.Destination = wdSendToPrinter
.ActiveDocument.MailMerge.Execute
End With
End Sub