View Single Post
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

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/...ttachments.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

--
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
"Hans" wrote in message
...
Is it possible to add a macro inside a dot file than when doing a
mailmerge
will select the correct email field so the user don't have to select which
is the email field manually? I have a program that generates a tab
separated
text file with data and opens the dot file and do the actual mailmerge.

What is missing is the automation to send the emails and this also
includes
selecting which field is the email address (for my template I know which
field contains the email address).

Ideally a solution working for Win2000 and higher would be best but if
there
are functionality in office XP or 2003 that makes this task easier please
let me know.

Regards
/Hans