ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA mailmerge from Excel (https://www.excelbanter.com/excel-programming/279645-vba-mailmerge-excel.html)

Dave Baxandall

VBA mailmerge from Excel
 
I have a problem starting Mailmerge from Excel. I've
created a macro in word that runs the mailmerge without
any problems. When I start word from Excel (which is also
the data source) I get a pop-up telling me that the excel
file is already open. I then need to choose read-only,
notify or cancel. This pop-up can take up to 60 seconds to
display. In the mean time the excel macro returns a error
message - 440 Method 'Run' of object '_Application' failed.

In debug the word code that takes a long time is.

Sub z_create_mail_merge(source As String)
'
' z_create_mail_merge Macro
' Macro recorded 2003/10/14 by TELUS
'
' Connection:="merge_it" is the range on the spreadsheet

ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
source, _
ConfirmConversions:=False, ReadOnly:=True,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=True, _
Format:=wdOpenFormatAuto, Connection:="merge_it",
SQLStatement:="", _
SQLStatement1:=""
....

Thanks in advance
Dave Baxandall



All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com