Mail Merge Automation

L

leaftye

I'm trying to automate a merge from an Excel spreadsheet that has
named range named "Database" into a Word document with merge code
named "M_1", "M_2", "M_3", etc.

When merging manually, it works, however when I run it from a macro
even a macro recorded from a scenario that just worked, it gives me a
"Invalid Merge Field" dialog box or opens up the dialog box where i
asks for me to pick a Table, depending on if I run the code from Exce
or Word.

Anyway, here's the line of code in my Excel vba that I'm sure i
causing all my frustration:

objWord.ActiveDocument.MailMerge.OpenDataSource
NAME:=\"C:\TEXT.XLS\",
ConfirmConversions:=True, _
ReadOnly:=False, _
LINKTOSOURCE:=TRUE,
AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
CONNECTION:=\"DATABASE\",
* SQLStatement:="SELECT * FROM c:\test.xls", _*
SQLStatement1:="", _
SubType:=wdMergeSubTypeOther

I emphasized the parts of the code I believe are required. I think al
the other lines can be removed, but I've left them in place for no
since removing them doesn't seem to make a difference.

So what's it look like I'm doing wrong?

If it helps, I'll make Excel and Word test files to upload. I would'v
done it now, but there's quite a bit of company info I'd need to tri
out before posting it
 
L

leaftye

Bump for help heading into a slow holiday. Please help me find a
solution to use tomorrow while I'm bored out of my mind tomorrow at
work!
 
Top