I recorded a macro for mail merge in Word. I cut and pasted it into Access and incorporated some code from the A97 Developers manual, but I’m missing something. I’m getting a Type Mismatch (Error13). When I debug, it’s halting at “Set objWd = GetObject(“K:\Client\Letters\Solicitation Form Letter.dot”)”.
Hopefully someone can help me understand what the very long help file is trying to say in english.
Also, when the word file opens and goes through “MailMerge.OpenDataSource”, it is opening another version of the Access database that triggered Word in the first place. What must I change to get it to read the query from the database that’s already open? The code I have so far is below. THANKS ALL, for your help.
Option Compare Database
Option Explicit
Dim objWd As Document
Function Merge()
‘ setandmerge Macro
‘ Macro recorded 04/16/01 by Renee Moffett
Set objWd = GetObject(“K:\Philips Lighting\Letters\Solicitation Form
Letter.dot”)
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource_ Name:= “\\LOU1\Kommon\Client\Philips 1.0.mdb”,
ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, _
PasswordDocument:=””, PasswordTemplate:=””,
WritePasswordDocument:=””, _
WritePasswordTemplate:=””, Revert:=False,
Format:=wdOpenFormatAuto, _
Connection:=”QUERY qrySolicitation”, SQLStatement:= _
“SELECT * FROM [qrySolicitation]”, SQLStatement1:=””
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = “”
.MailSubject = “”
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
End Function