View Single Post
  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How to extract email addresses from a word document or htm web page?

Doug

I suspect that your macro may run into the same language issues that the
search string is having problems with i.e. the escape character \ before the
@


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Doug Robbins - Word MVP wrote:
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


wrote in message
oups.com...
Hello,
I'm in trouble because I'm trying to find the way to extract some
e-mail addresses that are in a .doc document I have that I also have
in txt format or .htm format
The word document is several pages and he has a lot of e-mail
addresses that I cannot just copy and past with the search tool
because they are too much.
How do I do to extract all the email addresses from the word
document? Thanks!