From: Gordon on
Hi

I have 1900 lines of information. Each one begins with a persons name,
followed by a random gap then followed by an email address. What I need is
just the email addresses. SO the macro needs to look at each line. Identify
where the persons name ends, delete, delete the space afterwards, and leave
the email address intact.

Any help appreciated. I know excel VB, not Word!

Thanks Gordon
From: DaveLett on
Hi Gordon,
You don't NEED a macro to get this done; instead, you can use a wildcard
search and replace. Open the Find and Replace dialog box, select the Use
Wildcards check box, and place the following in the Find what box:

[A-z]{1,}

Leave the Replace with box empty. Do a Replace All.

HTH,
Dave

P.S. If this must be a macro, just let me know.

"Gordon" wrote:

> Hi
>
> I have 1900 lines of information. Each one begins with a persons name,
> followed by a random gap then followed by an email address. What I need is
> just the email addresses. SO the macro needs to look at each line. Identify
> where the persons name ends, delete, delete the space afterwards, and leave
> the email address intact.
>
> Any help appreciated. I know excel VB, not Word!
>
> Thanks Gordon
From: Gordon on
Hi Dave

Is there a Macro too...? (please?)

G

"DaveLett" wrote:

> Hi Gordon,
> You don't NEED a macro to get this done; instead, you can use a wildcard
> search and replace. Open the Find and Replace dialog box, select the Use
> Wildcards check box, and place the following in the Find what box:
>
> [A-z]{1,}
>
> Leave the Replace with box empty. Do a Replace All.
>
> HTH,
> Dave
>
> P.S. If this must be a macro, just let me know.
>
> "Gordon" wrote:
>
> > Hi
> >
> > I have 1900 lines of information. Each one begins with a persons name,
> > followed by a random gap then followed by an email address. What I need is
> > just the email addresses. SO the macro needs to look at each line. Identify
> > where the persons name ends, delete, delete the space afterwards, and leave
> > the email address intact.
> >
> > Any help appreciated. I know excel VB, not Word!
> >
> > Thanks Gordon
From: DaveLett on
Hi Gordon,

I think this is what you're looking for:
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.text = "[A-z]{1,} {1,}"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.text = ""
End With
.Execute Replace:=wdReplaceAll
End With
End With


Dave