View Single Post
 
Old 07-12-2024, 08:26 AM
gmaxey gmaxey is offline Windows 10 Office 2019
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

That would happen it the first word in the document was bold and no open paren preceding it.


Code:
Sub BoldTextWithinBrackets_AddQuotes()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  Application.ScreenUpdating = False
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Wrap = wdFindStop
    .Format = True
    .MatchWildcards = False
    .Font.Bold = True
    While .Execute
      On Error GoTo Err_Handler
      If oRng.Characters.First.Previous = Chr(40) And oRng.Characters.Last.Next = Chr(41) Then
        oRng.InsertBefore Chr(34)
        oRng.Characters.First.Font.Bold = True
        oRng.InsertAfter Chr(34)
      End If
Err_Handler:
      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/
Reply With Quote