Kamran
Kamran

Reputation: 4100

How to select a specific bullet in VBA

I have many bullets in a Word document.
I want to select only a specific bullet i.e. u) and make its text red.
I manage to count number of bullets. But I am not sure how to select a specific bullet.

Sub FindBullet()

Dim oPara As Word.Paragraph
Dim count As Integer
count = 0

'Select Entire document
Selection.WholeStory

With Selection
    For Each oPara In .Paragraphs
        If oPara.Range.ListFormat.ListType = WdListType.wdListSimpleNumbering Then
            count = count + 1
        End If
    Next
End With
'Gives the count of bullets in a document
MsgBox count

End Sub

Upvotes: 2

Views: 938

Answers (1)

L42
L42

Reputation: 19727

Try this:

Selection.WholeStory
With Selection
    For Each oPara In .Paragraphs
        If oPara.Range.ListFormat.ListType = wdListSimpleNumbering Then _
            If oPara.Range.ListFormat.ListString = "u)" Then _
                oPara.Range.Font.ColorIndex = wdRed
    Next
End With

You're only missing the Liststring property which returns the Numbering value.
Hope this helps.

Upvotes: 2

Related Questions