none
VBA Word - Bullet Points Color RGB RRS feed

  • Question


  • Hi friends,

     

    I am trying to change some bullet points and add some text to it.

     

    If the Bullet points are red insert the word red before it

    And blue for blue

    Etc

     

     

     

    I have got started but no bullets changed or text inserted.

      
        
        
        Sub ListBulletsColors()
        
        
        For Each oPara In ActiveDocument.Paragraphs
        Set oRng = oPara.Range
        oInsertBefore = "": oInsertAfter = ""
        oListColor = oRng.Font.Color
        
    
        
        Select Case oListColor
        
        ' List RGB Colors
        '-----------------------------
        Case RGB(0, 176, 240)
        oInsertBefore = "Blue"
      
        
        Case RGB(255, 0, 0)
        oInsertBefore = "Red"
        End Select
        
        
        If oRng.Font.Color <> oListColor And oRng.ListFormat.ListType = wdListBullet Then
        oRng.ListFormat.RemoveNumbers _
        NumberType:=wdNumberParagraph
        oRng.InsertBefore Text:=""    << ??
    
            
        End If
        Next oPara
        End Sub
    

     

    Please have a look thank you


    Cheers Dan :)

    Thursday, February 16, 2017 1:49 PM

All replies

  • I don't really understand what you want, and your code doesn't make much sense, but see if you can use the following as starting point:

    Sub ListBulletsColors()
        Dim oPara As Paragraph
        Dim oRng As Range
        Dim oListColor As Long
        Dim oInsertBefore As String
    
        For Each oPara In ActiveDocument.Paragraphs
            Set oRng = oPara.Range
    
            If oRng.ListFormat.ListType = wdListBullet Then
                oListColor = oRng.Font.Color
    
                Select Case oListColor
                ' List RGB Colors
                '-----------------------------
                    Case RGB(0, 176, 240)
                        oInsertBefore = "Blue"
                    Case RGB(255, 0, 0)
                        oInsertBefore = "Red"
                    Case Else
                        oInsertBefore = "Other"
                End Select
    
                oRng.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
                oRng.InsertBefore Text:=oInsertBefore & vbTab
            End If
        Next oPara
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, February 20, 2017 7:07 AM