View Single Post
  #2   Report Post  
Posted to microsoft.public.word.newusers
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Find and Replace

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 7 Jan 2007 13:10:00 -0800, Island Girl
wrote:

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!