G
Grant Reid
Hi
I hope someone out there can help me. I'm busy with a POC which requires an
Email mail merge via Word with the Email addresses for the recipients coming
from a table within a MS SQL database.
I attempted to record a macro, this initial attempt to record the macro was
succesful and mail was actually sent to the desired recipients. However,
when I attempted to run the recorded macro again I got the following error;
"Mail Merge - Record 1 contained too few data fields", followed by the
following; "Word cannot merge documents that can be distributed by mail or
fax without a valid mail address. Choose the Setup button to select a mail
address data field"
It is obvious to me that the recorded macro did not actually record the
address field info that I entered during the mail merge wizard, see recorded
macro below......
Sub Macro1()
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\grantr.EMPIRE\My Documents\My Data
Sources\grantntsrv SIM Recipients.odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=SQLOLEDB.1;Password=sybase;Persist Security Info=True;User
ID=sa;Initial Catalog=SIM;Data Source=grantntsrv;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=GRANTNTSRV;Use
Encryption for Data=False;Tag with column c" _
, SQLStatement:="SELECT * FROM ""Recipients""", SQLStatement1:="", _
SubType:=wdMergeSubTypeOther
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
The table name is "Recipients" and the Email addresses are contained in a
field named "Addresses". I wish I could do this myself, but I need to
deliver on this ASAP due to the time constraints imposed by the POC
delivery.
Kind Regards - Grant
I hope someone out there can help me. I'm busy with a POC which requires an
Email mail merge via Word with the Email addresses for the recipients coming
from a table within a MS SQL database.
I attempted to record a macro, this initial attempt to record the macro was
succesful and mail was actually sent to the desired recipients. However,
when I attempted to run the recorded macro again I got the following error;
"Mail Merge - Record 1 contained too few data fields", followed by the
following; "Word cannot merge documents that can be distributed by mail or
fax without a valid mail address. Choose the Setup button to select a mail
address data field"
It is obvious to me that the recorded macro did not actually record the
address field info that I entered during the mail merge wizard, see recorded
macro below......
Sub Macro1()
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\grantr.EMPIRE\My Documents\My Data
Sources\grantntsrv SIM Recipients.odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=SQLOLEDB.1;Password=sybase;Persist Security Info=True;User
ID=sa;Initial Catalog=SIM;Data Source=grantntsrv;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=GRANTNTSRV;Use
Encryption for Data=False;Tag with column c" _
, SQLStatement:="SELECT * FROM ""Recipients""", SQLStatement1:="", _
SubType:=wdMergeSubTypeOther
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
The table name is "Recipients" and the Email addresses are contained in a
field named "Addresses". I wish I could do this myself, but I need to
deliver on this ASAP due to the time constraints imposed by the POC
delivery.
Kind Regards - Grant