Here's a Macro to extract all of the email addresses from a document, but
you would probably be better off to modify the technique used in the article
"Mail Merge to E-mail with Attachments" at
http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm
Sub CopyAddressesToOtherDoc()
Dim Source As Document, Target As Document, myRange As Range
Set Source = ActiveDocument
Set Target = Documents.Add
Application.ScreenUpdating = False
Source.Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="[+0-9A-z._-]{1,}\@[A-z.]{1,}", _
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set myRange = Selection.Range
Target.Range.InsertAfter myRange & vbCr
Loop
End With
Selection.HomeKey Unit:=wdStory
Target.Activate
End Sub

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Is it possible to add a macro inside a dot file than when doing a
> mailmerge
[quoted text clipped - 15 lines]
> Regards
> /Hans
Hans - 01 Feb 2005 12:06 GMT
Thanks Doug for your help but I think I was unclear what I want to do.
I have an application that creates a tab separated file (lets call this
data.txt) where one column contains the email address. The application opens
the template file and the template reads the data.txt file. If they want to
mail this document they can click the "Merge to Email" button but then you
would have to select which field is the email field. I wonder if it is
possible to add macro code so they don't need to click on the "Merge to
Email" button where you manually have to select the email field, enter a
subject and click OK). Ideally it should
1. select the correct email field automatically (I know the name of the
column that contains the email address )
2. Set a subject (ideally they would like to have dynamic merge instructions
in the subject as well to customize the subject line for every email. For
example add the contact name which is also part of the data.txt file. Is it
possible to have mailmerge instructions in the subject?)
3. Do the actual send.
Either this could be executed in an event (open) or maybe a button could be
created that will do step 1-3 automatically. I know this sounds silly but
they think 3-4 clicks is too much to do. They want single click
functionality.
I guess I can solve this by following the steps in the URL you sent but it
seems to be overkill in this case.
Regards
/Hans
P.s Sorry for my english but I guess it is better than your swedish :-) D.s
Doug Robbins - 01 Feb 2005 23:38 GMT
I understood exactly what you want to do and the information that I posted
should give you a few ideas about how to go about it.

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Thanks Doug for your help but I think I was unclear what I want to do.
>
[quoted text clipped - 35 lines]
> P.s Sorry for my english but I guess it is better than your swedish :-)
> D.s
Hans - 03 Feb 2005 06:47 GMT
Hi Doug!
Ok I guess I will have to look deeper into your example. I was hoping this
was a three line macro. The dialog where you select the field containing the
email addrss, setting the subject and then send the emails looks like two
property settings to me and one call to a method send so I was hoping it was
possible to set these programtically (the properties and method below don't
exist but I was hoping that they do exist but maybe with another name).
Mydocument.active_email_property =
"<my_mailmerge_field_containing_email_address>"
Mydocument.subject_for_email = "Some subject"
Mydocument.send
Thanks for your help!
Regards
/Hans