View Single Post
 
Old 09-26-2024, 05:47 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 294
vivka is on a distinguished road
Default

Hi, Shelley Lou! If need be, change selection to ActiveDocument.

Code:
Sub Embolden_Rng_1()
 'Embolden strings including colons.

 Dim oRng As range
Set oRng = selection.range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchWildcards = True
 'Find text from a para start until the 1st tab or colon (including):
    .text = "^13[!^13]@[^t:]"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
  End With
Set oRng = Nothing
End Sub
Code:
Sub Embolden_Rng_2()
'Embolden strings excluding colons.

Dim oRng As range
Set oRng = selection.range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchWildcards = True
'Find text from a para start until the 1st tab or colon:
    .text = "(^13[!^13]@)([^t:])"
    While .Execute And oRng.InRange(selection.range)
        oRng.End = oRng.End - 1
        oRng.Font.Bold = True
        oRng.Collapse wdCollapseEnd
    Wend
  End With
Set oRng = Nothing
 End Sub
Code:
Sub Embolden_Rng_3()
'Embolden strings from para starts until 1st colon/tab
'(excluding colons & possible starting round/square brackets).

Dim oRng As range
Set oRng = selection.range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchWildcards = True
'Find text from a para start until 1st tab/colon:
    .text = "(^13[!^13]@)([^t:])"
    While .Execute And oRng.InRange(selection.range)
        If oRng.Characters(2) Like "[\(\[]" Then oRng.start = oRng.start + 2
        oRng.End = oRng.End - 1
        oRng.Font.Bold = True
        oRng.Collapse wdCollapseEnd
    Wend
  End With
Set oRng = Nothing
End Sub
Reply With Quote