VBA or macro code to extract email addresses from a Word document, into a new blank document ?

N

Nik Bedwell

Hello,

I would be very grateful for some assistance in creating VBA code or a macro
which can extract email addresses from a Word document, and place them into
a new blank document? IE, original document format is:

name surname1
address1 address2 address3 postcode email [email protected]
name surname2
address1 address2 address3 postcode email [email protected]

Macro creates a new document containing just:

[email protected]
[email protected]

There is no guarantee that all email addresses are in this exact location
(most appear to be), but certainly the assumption is that there is a 'space'
at the start of the email address and a 'space' or 'return' at the end.

Many thanks for your help.

N
 
K

Klaus Linke

Hi Nick,

You could make a copy of the document, and delete everything that's not in
the "Hyperlink" character style.

If the rest of your text isn't coloured, you can replace "Format > Font >
Color: Automatic" with paragraph marks ^p.
Then replace multiple paragraph marks with a single paragraph mark:
Check "Match wildcards",
Find what: (^13){2,}
Replace with: \1

Regards,
Klaus
 
N

Nik Bedwell

Thankyou, this worked perfectly :)

Klaus Linke said:
Hi Nick,

You could make a copy of the document, and delete everything that's not in
the "Hyperlink" character style.

If the rest of your text isn't coloured, you can replace "Format > Font >
Color: Automatic" with paragraph marks ^p.
Then replace multiple paragraph marks with a single paragraph mark:
Check "Match wildcards",
Find what: (^13){2,}
Replace with: \1

Regards,
Klaus
 
Top