Email adresses

G

Guest

i have a text from my supplier and it includes hundreds of email adresses
with lots of text and i dont want to select all email adresses one-by-one.Can
Word have an option like selecting all the email adresses on a word document?
 
D

Doug Robbins - Word MVP

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

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

--
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
 
T

Tony Jollans

If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses

--
Enjoy,
Tony


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

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

--
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

fsa said:
i have a text from my supplier and it includes hundreds of email adresses
with lots of text and i dont want to select all email adresses
one-by-one.Can
Word have an option like selecting all the email adresses on a word
document?
 
G

Graham Mayor

If the email addresses are not hyperlinks, you would have to run autoformat
first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


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

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

--
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

fsa said:
i have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a word
document?
 
T

Tony Jollans

Good point. I hadn't thought of that. I just cut and pasted a post I had
made somewhere else earlier in the day.

For completeness, precede my instructions with ..

Ctrl+A
Format > Autoformat > OK

And follow them with ..

Ctrl+F6 to switch back to the original document
Ctrl+Z to undo the autoformatting

--
Enjoy,
Tony


Graham Mayor said:
If the email addresses are not hyperlinks, you would have to run autoformat
first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


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

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

--
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 have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a word
document?
 
G

Graham Mayor

You would also have to check the autoformat options to ensure that the
convert hyperlinks option is checked - it might not be ;)
With so many steps, I think this is a job for a macro, but I baulked at
getting the search routine to find *and select* all occurrences of "^d
hyperlink "mailto" as you can from the find dialog. Obviously there's a
trick - or rather a command line - I'm missing here :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
Good point. I hadn't thought of that. I just cut and pasted a post I
had made somewhere else earlier in the day.

For completeness, precede my instructions with ..

Ctrl+A
Format > Autoformat > OK

And follow them with ..

Ctrl+F6 to switch back to the original document
Ctrl+Z to undo the autoformatting


Graham Mayor said:
If the email addresses are not hyperlinks, you would have to run
autoformat first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


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

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

--
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 have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a
word document?
 
T

Tony Jollans

You are correct, of course :)

Unfortunately the Select All option is not available from VBA - I guess it's
related to the fact that VBA can't handle non-contiguous Selections.

--
Enjoy,
Tony


Graham Mayor said:
You would also have to check the autoformat options to ensure that the
convert hyperlinks option is checked - it might not be ;)
With so many steps, I think this is a job for a macro, but I baulked at
getting the search routine to find *and select* all occurrences of "^d
hyperlink "mailto" as you can from the find dialog. Obviously there's a
trick - or rather a command line - I'm missing here :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
Good point. I hadn't thought of that. I just cut and pasted a post I
had made somewhere else earlier in the day.

For completeness, precede my instructions with ..

Ctrl+A
Format > Autoformat > OK

And follow them with ..

Ctrl+F6 to switch back to the original document
Ctrl+Z to undo the autoformatting


Graham Mayor said:
If the email addresses are not hyperlinks, you would have to run
autoformat first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony Jollans wrote:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


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

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

--
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 have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a
word document?
 
S

Suzanne S. Barnhill

If the addresses are hyperlinks, you could also search for the Hyperlink
character style (with field codes NOT displayed).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Graham Mayor said:
If the email addresses are not hyperlinks, you would have to run autoformat
first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


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

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

--
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 have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a word
document?
 
G

Graham Mayor

I was afraid that was going to be the problem :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
You are correct, of course :)

Unfortunately the Select All option is not available from VBA - I
guess it's related to the fact that VBA can't handle non-contiguous
Selections.


Graham Mayor said:
You would also have to check the autoformat options to ensure that
the convert hyperlinks option is checked - it might not be ;)
With so many steps, I think this is a job for a macro, but I baulked
at getting the search routine to find *and select* all occurrences
of "^d hyperlink "mailto" as you can from the find dialog. Obviously
there's a trick - or rather a command line - I'm missing here :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony said:
Good point. I hadn't thought of that. I just cut and pasted a post I
had made somewhere else earlier in the day.

For completeness, precede my instructions with ..

Ctrl+A
Format > Autoformat > OK

And follow them with ..

Ctrl+F6 to switch back to the original document
Ctrl+Z to undo the autoformatting


If the email addresses are not hyperlinks, you would have to run
autoformat first to make them so.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Tony Jollans wrote:
If you have Word 2002 or 2003 you can do this without code ...

Press Alt+F9 to toggle field codes
Press Ctrl+F to get the Find Dialog
In the Find what box enter ^d hyperlink "mailto
Check the "Highlight all Items" checkbox
Click on "Find All"
Click on Close
Press Alt+F9 to toggle field codes off
Press Ctrl+C to copy all the e-mail hyperlinks found
Press Ctrl+N to open a new document
Press Ctrl+V to paste the e-mail addresses


message 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

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

--
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 have a text from my supplier and it includes hundreds of email
adresses with lots of text and i dont want to select all email
adresses one-by-one.Can
Word have an option like selecting all the email adresses on a
word document?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top