View Single Post
 
Old 09-25-2024, 10:40 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I think in this case you will need to find within a find:


Code:
Sub DPU_BoldTextWithinBrackets_AddQuotes2()
Dim oRng As Range
Dim oRng2 As Range
  Set oRng = ActiveDocument.Range
  Application.ScreenUpdating = False
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "\(*\)"
    .Wrap = wdFindStop
    .Format = True
    .MatchWildcards = True
    While .Execute
      Set oRng2 = oRng.Duplicate
      With oRng2.Find
        .Format = True
        .Font.Bold = True
        Do While .Execute
          If oRng2.InRange(oRng) Then
          If Not oRng2.Characters.First = Chr(34) Then
            oRng2.InsertBefore Chr(34)
            oRng2.Characters.First.Font.Bold = True
            oRng2.InsertAfter Chr(34)
            oRng2.Collapse wdCollapseEnd
          End If
        Else
          Exit Do
        End If
      Loop
      End With
      oRng.Collapse wdCollapseEnd
    Wend
  End With
  Application.ScreenUpdating = True
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by gmaxey; 09-25-2024 at 12:50 PM.
Reply With Quote