Group: microsoft.public.word.vba.general
From: =?Utf-8?B?RWxlc3N2aWU=?=
Date: Thursday, February 28, 2008 5:04 PM
Subject: HOW TO KEEP A RANGE INSIDE QUOTES?

Hi, programmers,

I have a question on a very helpful macro posted here for finding and
underlining text between quotation marks. It works great--except when quotes
are preceded or followed by a comma or Wildcard.

In that case, the range extends right on through to the next instance of
quotes that DON’T have any commas right before or after them.

Is there a way to keep the range from extending in these instances? Thank
you for all your help.

Here is the code:

Sub FindAndUnderlineTextInQuotes()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "[^0034^0147]<*>[^0034^0148]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
If oRng.Find.Found = True Then
With oRng
.MoveEnd Unit:=wdCharacter, Count:=-1
.MoveStart Unit:=wdCharacter, Count:=1
.Font.Underline = True
.Collapse wdCollapseEnd
End With
End If
Loop
End With
End Sub


Thanks!

-Lynne