LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Mail Merge Automation


I'm trying to automate a merge from an Excel spreadsheet that has a
named range named "Database" into a Word document with merge codes
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 an
"Invalid Merge Field" dialog box or opens up the dialog box where it
asks for me to pick a Table, depending on if I run the code from Excel
or Word.

Anyway, here's the line of code in my Excel vba that I'm sure is
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 all
the other lines can be removed, but I've left them in place for now
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've
done it now, but there's quite a bit of company info I'd need to trim
out before posting it.




--
leaftye
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code launches Mail Merge but disables the Mail Merge austris Excel Discussion (Misc queries) 0 October 14th 06 01:11 AM
Mail Merge 255 Character Limit Problem Colin Excel Discussion (Misc queries) 0 March 9th 06 09:25 PM
Difficult for me, probably basic to you onlyjohn Excel Worksheet Functions 1 February 3rd 06 05:14 PM
Different graphic for each record in mail merge document Alex St-Pierre Charts and Charting in Excel 1 May 4th 05 07:26 PM
Extract Data for Mail Merge Rashid Khan Excel Discussion (Misc queries) 7 December 24th 04 05:47 PM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"