Find and Replace

G

Guest

Is there a way in the Find and Replace dialog box of telling Word to
underline a whole sentence but not the period following it?

I know how to underline the sentence with the period, but somehow I'm having
a mental block concerning leaving the period without an underline.

Here's the unbelievable part: I have a function key assigned to this very
thing, and it works every time! But I don't know whether I stumbled across a
way to do it at some point or whether one of you wonderful people wrote a
macro for it.

No matter how it got there, I'd really like to know if Find and Replace
alone can do it.

Thank you so much for helping me to be a better word processor!
 
J

Jay Freedman

Somebody clever may come along and prove me wrong, but I don't think
Replace, even with wildcards, can do that trick. The reason is that
the entire replacement can have only one value for each kind of
formatting (underline, bold, etc.) -- there's no way to say "replace
part of the found text with one kind of format and the rest with
another kind". What you have to do is set things up so all the found
text requires the same format. That takes at least two steps, so a
macro is necessary.

The macro doesn't have to use Find/Replace. For example, here's one
that doesn't:

Sub UnderlineSentence()
Dim oRg As Range
Set oRg = Selection.Sentences(1)
With oRg
.Collapse wdCollapseStart
.MoveEndUntil cset:=".?!", Count:=wdForward
.Underline = wdUnderlineSingle
End With
Set oRg = Nothing
End Sub

Put the cursor anywhere inside the desired sentence and run the macro.

As for finding out what you already have: Go to Tools > Customize >
Keyboard. Choose any command in the dialog, put the cursor in the
"Press new shortcut key" box, and press the function key that's
already assigned to your underlining function. The dialog will show
"Currently assigned to:" followed by the name and location of the
macro. Cancel out of the dialog without making any assignment. Then
you can track down the macro and see what the code does.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
J

Jay Freedman

:)
You're welcome!

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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

Similar Threads


Top