newbie needs code help for word mail merge 
Author Message
 newbie needs code help for word mail merge

I recorded a macro for mail merge in word 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:\Philips Lighting\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\Philips Lighting\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



Fri, 03 Oct 2003 23:08:27 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. NEED HELP, Coding Access to Word Mail Merge :-)

2. Word Newbie needs to do a complex mail merge

3. Word Mail Merge Err - Word could not merge...

4. Word/Access mail merge automation help needed

5. Newbie Word Mail Merge

6. VB Code for Word Mail Merge Wizerd

7. Getting Error Code:5922 when running word mail merge on Office XP

8. Transfering Text from Access to Word for Mail Merge through Code

9. mail merge coding with MS access in word

10. Transfer Text from Access to Word for Mail Merge by Code

11. Formatting Merge Fields in Word Mail Merge

12. HTML forms, Word, e-mail and mail merge

 

 
Powered by phpBB® Forum Software