View Single Post
 
Old 06-13-2024, 04:05 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this approach - you need to select the paragraphs you want to examine first.
Code:
Sub BoldOfYouSir()
  Dim aPar As Paragraph, iColon As Integer, iTab As Integer, aRng As Range, iFirst As Integer
  For Each aPar In Selection.Range.Paragraphs
    Set aRng = aPar.Range
    iColon = InStr(aRng.Text, ":")
    iTab = InStr(aRng.Text, vbTab)
    If iColon > 0 Then
      If iTab = 0 Then
        aRng.End = aRng.Start + iColon
      Else
        iFirst = IIf(iColon < iTab, iColon, iTab)
        aRng.Collapse Direction:=wdCollapseStart
        aRng.End = aRng.Start + iFirst
      End If
      aRng.Font.Bold = True
    ElseIf iTab > 0 Then
      aRng.End = aRng.Start + iTab
      aRng.Font.Bold = True
    End If
  Next aPar
End Sub
Edit: I see you added sample files and the list elements are hard coded. The code I provided ignores automatic numbering but treats those hard coded lists as if they contain a tab (which they do). I don't know how your real source lists are done so this code may or may not be what you wanted.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia

Last edited by Guessed; 06-13-2024 at 04:09 AM. Reason: Viewed your sample attachments
Reply With Quote