T
Tony G
Hello world!,
Below is part of a routine to e-mail merge from a contact
database to Word, sending the document as the body of the
message. At least, that what I want it to do but it just
fails silently - I end up with an unmerged document open
and no action.
Any help greatly appreciated.
Sub MergeIt(Optional ForEMail As Boolean)
Dim Op As Integer
Dim wrdApp As Word.Application
Dim myDoc As Word.Document
Dim Eresponse As String
Set wrdApp = New Word.Application
wrdApp.Visible = True
If ForEMail = True Then
Eresponse = InputBox("Please enter a subject line for the
e-mail merge", "E-mail Merge")
If Eresponse = "" Then Exit Sub
Set myDoc = wrdApp.Documents.Open(FileName:="U:\Merge
Letters\" & Forms!campaigns!Combo347.Value, ReadOnly:=True)
myDoc.MailMerge.OpenDataSource Name:="U:\MF Contact
Manager.mdb", ReadOnly:=True, LinkToSource:=False,
Connection:="QUERY CampaignsQuery", SQLStatement:="SELECT
* FROM [CampaignsQuery] WHERE " & Forms!campaigns!.Filter
With myDoc.MailMerge
.Destination = wdSendToEmail
.MailAsAttachment = False
' .MailFormat = wdMailFormatHTML
.MailSubject = Eresponse
.MailAddressFieldName = "EmailName"
.Execute
End With
myDoc.Application.Documents(Forms!campaigns!
Combo347.Value).Close False
End If
(rest of routine for other merge types)
...
Below is part of a routine to e-mail merge from a contact
database to Word, sending the document as the body of the
message. At least, that what I want it to do but it just
fails silently - I end up with an unmerged document open
and no action.
Any help greatly appreciated.
Sub MergeIt(Optional ForEMail As Boolean)
Dim Op As Integer
Dim wrdApp As Word.Application
Dim myDoc As Word.Document
Dim Eresponse As String
Set wrdApp = New Word.Application
wrdApp.Visible = True
If ForEMail = True Then
Eresponse = InputBox("Please enter a subject line for the
e-mail merge", "E-mail Merge")
If Eresponse = "" Then Exit Sub
Set myDoc = wrdApp.Documents.Open(FileName:="U:\Merge
Letters\" & Forms!campaigns!Combo347.Value, ReadOnly:=True)
myDoc.MailMerge.OpenDataSource Name:="U:\MF Contact
Manager.mdb", ReadOnly:=True, LinkToSource:=False,
Connection:="QUERY CampaignsQuery", SQLStatement:="SELECT
* FROM [CampaignsQuery] WHERE " & Forms!campaigns!.Filter
With myDoc.MailMerge
.Destination = wdSendToEmail
.MailAsAttachment = False
' .MailFormat = wdMailFormatHTML
.MailSubject = Eresponse
.MailAddressFieldName = "EmailName"
.Execute
End With
myDoc.Application.Documents(Forms!campaigns!
Combo347.Value).Close False
End If
(rest of routine for other merge types)
...