how can i underline only 5 letter words?

R

ruan99

I have an essay written but I have to underline only the 5 letter words in
it. I do not want to go back and underline them all individually, so I am
wondering if there is a way to mass underline only 5 letter words. Thank you
 
S

Stefan Blom

Press Ctrl+H to display the Find & Replace dialog box. Click the More button
(if necessary) to see all options. Check the "Use wildcards" option. Specify
the following:

"Find what": <?????>

"Replace with": (leave blank; choose Underline formatting in Format, Font)

Then press Replace All.
 
D

Doug Robbins - Word MVP on news.microsoft.com

Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) = True
Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With


--
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, originally posted via msnews.microsoft.com
 
G

Greg Maxey

Doug,

That misses the first word of the document if 5 characters and the last word
of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted with
underline.

Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



ruan99 said:
I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
S

Suzanne S. Barnhill

Is a macro really necessary when the simple Find operation Stefan proposed
should do the job?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Greg Maxey said:
Doug,

That misses the first word of the document if 5 characters and the last
word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted with
underline.

Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



ruan99 said:
I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
G

grammatim

Thank you.

Is a macro really necessary when the simple Find operation Stefan proposed
should do the job?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org




That misses the first word of the document if 5 characters and the last
word of a sentence if 5 characters.
This seems to work:  Find:  <[! ]{3}>  Replace with:  ^&  formatted with
underline.
Doug said:
Use a macro containing the following code:
Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
       MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
       True Set myRange = Selection.Range
       Selection.Collapse wdCollapseEnd
       myRange.Start = myRange.Start + 1
       myRange.End = myRange.End - 1
       myRange.Font.Underline = wdUnderlineSingle
   Loop
End With
I have an essay written but I have to underline only the 5 letter
words in it.  I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words.  Thank you
My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org-
 
S

Suzanne S. Barnhill

I hadn't previously tested, but I just now did, and the Replace operation
does find a five-letter word at the beginning of the document and at the end
of a sentence, as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Thank you.

Is a macro really necessary when the simple Find operation Stefan proposed
should do the job?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org




That misses the first word of the document if 5 characters and the last
word of a sentence if 5 characters.
This seems to work: Find: <[! ]{3}> Replace with: ^& formatted with
underline.
Doug said:
Use a macro containing the following code:
Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With
I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org-
 
G

Greg Maxey

While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace with: ^&
formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for finding
three letter words. I wasn't disputing Stephan's proposal. If fact I didn't
even see it.

Looking at the issue a little closer <?????> may not completely fit the
bill. Is "don't" a five letter word, four letter word with an apostrophe, a
four letter word, or a two letter word connected to a three letter word with
an apostrophe? Is $12.95 a five letter word?, is a five character zip code
a five letter word or a just a number? I suppose if one is just looking for
words spelled with five letters of the alphabet then something like:

Find: <[A-Za-z]{5}>

may be more desirable.


Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


Greg Maxey said:
Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.

Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
S

Suzanne S. Barnhill

Agreed that "five characters" may not be the same as "five letters."

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Greg Maxey said:
While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace with:
^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for finding
three letter words. I wasn't disputing Stephan's proposal. If fact I
didn't even see it.

Looking at the issue a little closer <?????> may not completely fit the
bill. Is "don't" a five letter word, four letter word with an apostrophe,
a four letter word, or a two letter word connected to a three letter word
with an apostrophe? Is $12.95 a five letter word?, is a five character
zip code a five letter word or a just a number? I suppose if one is just
looking for words spelled with five letters of the alphabet then something
like:

Find: <[A-Za-z]{5}>

may be more desirable.


Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


Greg Maxey said:
Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
G

Greg Maxey

Really necessary? No. However, once a macro is prepared then it is there
for reuse whenever the need arises again. That is one advantages of a
macro. Additionally the macro could easily be enhances to make it very
easy to perform other similiar tasks like finding two letter words or 10
letter words. You could even adapt it adapt it to find one, two, three,
and four letter words all in one swoop. I believe that Doug posted the
macro with the intent to be helpful.
Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


Greg Maxey said:
Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.

Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
G

Greg Maxey

Are you disagreeing with "Find: <[! ]{3}> Replace with: ^& formatted with
underline" is not a macro?

Agreed that "five characters" may not be the same as "five letters."


Greg Maxey said:
While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace
with: ^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for
finding three letter words. I wasn't disputing Stephan's proposal. If
fact I didn't even see it.

Looking at the issue a little closer <?????> may not completely fit
the bill. Is "don't" a five letter word, four letter word with an
apostrophe, a four letter word, or a two letter word connected to a
three letter word with an apostrophe? Is $12.95 a five letter
word?, is a five character zip code a five letter word or a just a
number? I suppose if one is just looking for words spelled with
five letters of the alphabet then something like:

Find: <[A-Za-z]{5}>

may be more desirable.


Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


message Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass
underline only 5 letter words. Thank you
 
S

Suzanne S. Barnhill

Missed that part entirely. My quick take on your original post was that it
was a refinement to Doug's macro. As you may have gathered from my posts in
the private NG, I was a bit distracted yesterday.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Greg Maxey said:
Are you disagreeing with "Find: <[! ]{3}> Replace with: ^& formatted
with underline" is not a macro?

Agreed that "five characters" may not be the same as "five letters."


Greg Maxey said:
While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace
with: ^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for
finding three letter words. I wasn't disputing Stephan's proposal. If
fact I didn't even see it.

Looking at the issue a little closer <?????> may not completely fit
the bill. Is "don't" a five letter word, four letter word with an
apostrophe, a four letter word, or a two letter word connected to a
three letter word with an apostrophe? Is $12.95 a five letter
word?, is a five character zip code a five letter word or a just a
number? I suppose if one is just looking for words spelled with
five letters of the alphabet then something like:

Find: <[A-Za-z]{5}>

may be more desirable.



Suzanne S. Barnhill wrote:
Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


message Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass
underline only 5 letter words. Thank you
 
G

Gordon Bentley-Mix

Posting while distracted... I think you can get a ticket for that in NZ.
Although txting while driving is still perfectly legal. <g>
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!

Suzanne S. Barnhill said:
Missed that part entirely. My quick take on your original post was that it
was a refinement to Doug's macro. As you may have gathered from my posts
in the private NG, I was a bit distracted yesterday.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Greg Maxey said:
Are you disagreeing with "Find: <[! ]{3}> Replace with: ^& formatted
with underline" is not a macro?

Agreed that "five characters" may not be the same as "five letters."


message While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace
with: ^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for
finding three letter words. I wasn't disputing Stephan's proposal. If
fact I didn't even see it.

Looking at the issue a little closer <?????> may not completely fit
the bill. Is "don't" a five letter word, four letter word with an
apostrophe, a four letter word, or a two letter word connected to a
three letter word with an apostrophe? Is $12.95 a five letter
word?, is a five character zip code a five letter word or a just a
number? I suppose if one is just looking for words spelled with
five letters of the alphabet then something like:

Find: <[A-Za-z]{5}>

may be more desirable.



Suzanne S. Barnhill wrote:
Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


message Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass
underline only 5 letter words. Thank you
 
G

Graham Mayor

Texting (and using mobile phones) behind the wheel is illegal here, but so
widespread that you wouldn't know it. We also have one of the highest road
death rates in the Western World! Fortunately traffic is often so light that
most only kill themselves!

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


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

Posting while distracted... I think you can get a ticket for that in
NZ. Although txting while driving is still perfectly legal. <g>

Suzanne S. Barnhill said:
Missed that part entirely. My quick take on your original post was
that it was a refinement to Doug's macro. As you may have gathered
from my posts in the private NG, I was a bit distracted yesterday.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Greg Maxey said:
Are you disagreeing with "Find: <[! ]{3}> Replace with: ^&
formatted with underline" is not a macro?


Suzanne S. Barnhill wrote:
Agreed that "five characters" may not be the same as "five
letters." "Greg Maxey" <[email protected]>
wrote in
message While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace
with: ^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for
finding three letter words. I wasn't disputing Stephan's
proposal. If fact I didn't even see it.

Looking at the issue a little closer <?????> may not completely
fit the bill. Is "don't" a five letter word, four letter word
with an apostrophe, a four letter word, or a two letter word
connected to a three letter word with an apostrophe? Is $12.95 a
five letter word?, is a five character zip code a five letter
word or a just a number? I suppose if one is just looking for
words spelled with five letters of the alphabet then something
like: Find: <[A-Za-z]{5}>

may be more desirable.



Suzanne S. Barnhill wrote:
Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


in message Doug,

That misses the first word of the document if 5 characters and
the last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop,
MatchCase:=False) = True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5
letter words in it. I do not want to go back and underline
them all individually, so I am wondering if there is a way to
mass underline only 5 letter words. Thank you
 
S

Stefan Blom

Looking at the issue a little closer said:
bill. Is "don't" a five letter word, four letter word with an apostrophe,
a four letter word, or a two letter word connected to a three letter word
with an apostrophe? Is $12.95 a five letter word?, is a five character
zip code a five letter word or a just a number? I suppose if one is just
looking for words spelled with five letters of the alphabet then something
like:

Find: <[A-Za-z]{5}>

may be more desirable.

Good point.

--
Stefan Blom
Microsoft Word MVP



Greg Maxey said:
While wrong for the task at hand (Sorry), Find: <[! ]{3}> Replace with:
^& formatted with underline" is not a macro.

It is wrong, because I copied it from an old reference I had for finding
three letter words. I wasn't disputing Stephan's proposal. If fact I
didn't even see it.

Looking at the issue a little closer <?????> may not completely fit the
bill. Is "don't" a five letter word, four letter word with an apostrophe,
a four letter word, or a two letter word connected to a three letter word
with an apostrophe? Is $12.95 a five letter word?, is a five character
zip code a five letter word or a just a number? I suppose if one is just
looking for words spelled with five letters of the alphabet then something
like:

Find: <[A-Za-z]{5}>

may be more desirable.


Is a macro really necessary when the simple Find operation Stefan
proposed should do the job?


Greg Maxey said:
Doug,

That misses the first word of the document if 5 characters and the
last word of a sentence if 5 characters.

This seems to work: Find: <[! ]{3}> Replace with: ^& formatted
with underline.


Doug Robbins - Word MVP on news.microsoft.com wrote:
Use a macro containing the following code:

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=" [A-z]{5} ", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) =
True Set myRange = Selection.Range
Selection.Collapse wdCollapseEnd
myRange.Start = myRange.Start + 1
myRange.End = myRange.End - 1
myRange.Font.Underline = wdUnderlineSingle
Loop
End With



I have an essay written but I have to underline only the 5 letter
words in it. I do not want to go back and underline them all
individually, so I am wondering if there is a way to mass underline
only 5 letter words. Thank you
 
S

Stefan Blom

Greg Maxey said:
Stefan,

Sorry about the mispelling of your name down the thread.

Well, anyone can make a mistake. The strangest so far is a poster who called
me "Ms Blom." :)
 

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