Thread: Email filter
View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Email filter

On Mon, 8 Mar 2010 17:50:01 -0800, D Wood
wrote:

I have a 50 page word doc converted from pdf that has 1 email address per
page. Is it possible to filter/capture only email addresses at once instead
of copying and pasting from each page?


Yes, it's possible, by using a wildcard search in a macro. Wildcards
are explained in http://www.gmayor.com/replace_using_wildcards.htm.

The following macro will find the email addresses (that is, any
sequence of letters, numbers, and periods on both sides of an @
symbol) and copy them into a new document, one per paragraph. See
http://www.gmayor.com/installing_macro.htm if needed.

Sub CollectEmailAddresses()
Dim srcDoc As Document, dstDoc As Document
Dim oRg As Range

Set srcDoc = ActiveDocument
Set dstDoc = Documents.Add
Set oRg = srcDoc.Range

With oRg.Find
.MatchWildcards = True
.Text = "[A-Za-z0-9.]{1,}\@[A-Za-z0-9.]{1,}"
.Wrap = wdFindStop
While .Execute
dstDoc.Range.InsertAfter oRg.Text & vbCr
Wend
End With
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.