View Single Post
 
Old 11-28-2012, 09:04 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Something like this perhaps:

Code:
Sub subFindTextAndMoveItToEndOfTheSameParagraphAndUnderlineIt()
Dim oRng As Range
Dim oRngParent As Range
Dim strText As String
  strText = "Falsification  45 C.F.R. ?" & Chr(160) & "6891(a)(2):  "
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .ClearFormatting
    .Text = strText
    .Forward = True
    .Wrap = wdFindStop
    While .Execute
      With oRng
        .Select 'Why do you need to select it?
        .Text = Trim(.Text)
        .Font.Underline = wdUnderlineSingle
        Set oRngParent = .Paragraphs(1).Range
        With oRngParent
          .Characters.Last.Previous.InsertAfter " "
          .MoveEnd wdCharacter, -1
          .Collapse wdCollapseEnd
        End With
        .Cut
        With oRngParent
          .Paste
          .Characters.Last.Delete
          .Start = oRngParent.Paragraphs(1).Range.Start
          .Characters.First.Case = wdUpperCase
        End With
        .Start = oRngParent.End
      End With
    Wend 
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote