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 (e-mail address removed)
name surname2
address1 address2 address3 postcode email (e-mail address removed)

Macro creates a new document containing just:

(e-mail address removed)
(e-mail address removed)

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
 

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