I have some code that formats text before a colon bold for definitions. I'm currently working on a document where there are square brackets and/or opening brackets at the beginning of the paragraph before the colon but the code isn't making the text bold. I did try adding ([\(\[\]) but this didn't work. Any ideas?
Definitions.JPG
Code:
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchWildcards = True
.Replacement.ClearFormatting
'Find text before first tab or colon and format bold
.text = "([a-zA-Z0-9][!^13]@)([^t:])"
While .Execute
If oRng.Characters(1).Start = oRng.Paragraphs(1).Range.Characters(1).Start Then
oRng.Select
oRng.Font.Bold = True
If Not oRng.Characters.Last.Next = vbTab Then
oRng.text = Replace(oRng.text, ":", vbTab)
Else
oRng.Characters.Last.Delete
End If
End If
Wend
End With