I realise this Thread is very old but i'm using this macro to date and it's V.usefull.
Only problem is, It seems to have an issue with some emails that contain a hyphen "-"
Is there anything that can be done about this?
Many thanks!!
Quote:
Originally Posted by Doug Robbins - Word MVP
Run the following macro when the document containing the email addresses is
the active document
Macro to extract all of the email addresses from a document
Sub CopyAddressesToOtherDoc()
Dim Source As Document, Target As Document, myRange As Range
Set Source = ActiveDocument
Set Target = Documents.Add
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
--
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
[/i][/color]
|