Discussion Locked

Access/Word mailmerge automation

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

3 replies

by joescalia

ForACC: Creating Reports to Mail Merge Microsoft Access Data
try this : you can copy and paste or type it all in:
http://support.microsoft.com/support/kb/articles/Q98/7/98.ASP?LN=EN-US&SD=gn&FR=0&qry=mail%20merge&rnk=14&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97
For ACC97: Mail Merge to Word Opens Another Instance of Access

try this : you can copy and paste or type it all in:

http://support.microsoft.com/support/kb/articles/Q199/9/63.ASP?LN=EN-US&SD=gn&FR=0&qry=mail%20merge&rnk=13&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97
Good Luck,,,,

by learneverything

I tried following both links and got error messages. I've printed help files off the Knowledge Base and haven't had success. I'm trying a different tack now and having a little more luck. My main merge document is now a template. That seems to be working better, although it isn't completed yet.

Thanks for your help though.

This discussion is closed to new replies.