Use the following macro in place of the one in the article of the Word MVP
site:
Sub emailmergewithattachments()
'To create the email messages in
Dim Source As Document, Maillist As Document, TempDoc As Document
Dim datarange As Range
Dim i As Long, j As Long
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim mysubject As String, message As String, Title As String
Set Source = ActiveDocument
' Check if Outlook is running. If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
' Open the catalog mailmerge document
With Dialogs(wdDialogFileOpen)
.Show
End With
Set Maillist = ActiveDocument
' Show an input box asking the user for the subject to be inserted into the
email messages
message = "Enter the subject to be used for each email message." ' Set
prompt.
Title = " Email Subject Input" ' Set title.
' Display message, title
mysubject = InputBox(message, Title)
' Iterate through the Sections of the Source document and the rows of the
catalog mailmerge document,
' extracting the information to be included in each email.
For j = 1 To Source.Sections.Count - 1
Source.Sections(j).Range.Copy
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Subject = mysubject
.BodyFormat = olFormatHTML
.Display
Set objDoc = .GetInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
objSel.Paste
Set datarange = Maillist.Tables(1).Cell(j, 1).Range
datarange.End = datarange.End - 1
.To = datarange
For i = 2 To Maillist.Tables(1).Columns.Count
Set datarange = Maillist.Tables(1).Cell(j, i).Range
datarange.End = datarange.End - 1
.Attachments.Add Trim(datarange.Text), olByValue, 1
Next i
.Send
End With
Set oItem = Nothing
Next j
Maillist.Close wdDoNotSaveChanges
' Close Outlook if it was started by this macro.
If bStarted Then
oOutlookApp.Quit
End If
MsgBox Source.Sections.Count - 1 & " messages have been sent."
'Clean up
Set oOutlookApp = Nothing
End Sub
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Steve F" wrote in message
...
Graham,
PMFJI, but I'm working on a similar project and could use some assistance.
Both Doug Robbins macro and the MAPILabs tool build & send merge documents
to email -- no problem. However, I need the email message to look like
the
original letter, including the header & footer in the original Word file
which contain corporate logos as images.
Any suggestions?
Thank,
Steve Frye
"Graham Mayor" wrote:
There's not much of a learning curve with the MAPILabs tool and there is
a
trial version I believe. It simply provides an extra menu item in the
mailmerge wizard and the ensuing dialog boxes are self evident.
--
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
Terry wrote:
Thank you very much, Graham. Excellent advice.
I will probably go with the MAPILab add-in. I do use macros but I
suspect this one has a learning curve.
Please let me put in a recommendation to Mircosoft: the attachment
capability should be built into the Word/Outlook mail merge
procedure, in a simple box that allows the addition of an attachment.
Cheers,
Terry
"Graham Mayor" wrote:
See the article prepared by fellow MVP Doug Robbins at
http://word.mvps.org/FAQs/MailMerge/...ttachments.htm or
MAPILab's Mailmerge toolkit add-in for Outlook
http://www.mapilab.com/outlook/mail_merge/
--
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
Terry wrote:
I would like to do an email mail merge from a contact list in an
Excel file and include the same attachment (a PDF file) to each
email. I use Outlook (2007) for emails and more generally Office
2007.
I would like to insert the attachment only once. I cannot see a way
to do this during the mail merge process because the merge takes
place in Word and there does not seem to be a way to insert an
attached file prior to the mail merge. One has the Word menu system
rather than the Outlook email menu in which one can use
insert/attach file to attach a file.
Is there any way to do this: to set up the email during mail merge
so I insert the attached file only once?