locked
Use a macro to select all bulleted lists in word RRS feed

  • Question

  • Hi and thanks so much for your time!!!

    I am trying to find all instances of bulleted lists within a large selection in a word document and assign them a style as per our company branding.

    I have gotten pretty close, the following Macro selects the first line in the first bulleted list in the selection and assigns it the style I require.

    I just need some help getting it to select all the bullets in the doc.

    Sub findbullets22() 
    findbullets22 Macro 
    Dim oPara As Word.Paragraph 
    With Selection 
    For Each oPara In .Paragraphs 
    If oPara.Range.ListFormat.ListType = _ 
    WdListType.wdListBullet Then 
    oPara.Range.Select 
    End If 
    Next 
    End With 
    Selection.Style = ActiveDocument.Styles("List Paragraph") 
    End Sub 

    Any help you could provide would be amazing - I am starting to go nuts LOL :)



    • Edited by nicemanda Thursday, August 16, 2012 5:49 AM
    • Moved by Youen Zen Friday, August 17, 2012 2:32 AM To provide better support (From:Visual Basic General)
    Thursday, August 16, 2012 5:43 AM

Answers

  • Well if you want to process ALL bulleted paragraphs (not just what you select), then try:


    Sub findbullets22()
    Dim oPara As Word.Paragraph

    For Each oPara In ActiveDocument.Paragraphs
       If oPara.Range.ListFormat.ListType = _
             WdListType.wdListBullet Then
          oPara.Style = "List Paragraph"
       End If
    Next
    End Sub

    You do not actually need to Select anything.


    Word MVP

    • Proposed as answer by fumei2 Saturday, August 18, 2012 11:28 PM
    • Marked as answer by Quist Zhang Sunday, August 26, 2012 5:46 PM
    Friday, August 17, 2012 11:03 PM

All replies

  • Hi,

    this forum is part of the Visual Studio Developer Center. It has no relation to VBA. A better place to discuss your issue is here: http://social.msdn.microsoft.com/Forums/en-US/worddev/threads


    Armin

    Thursday, August 16, 2012 9:56 AM
  • Well if you want to process ALL bulleted paragraphs (not just what you select), then try:


    Sub findbullets22()
    Dim oPara As Word.Paragraph

    For Each oPara In ActiveDocument.Paragraphs
       If oPara.Range.ListFormat.ListType = _
             WdListType.wdListBullet Then
          oPara.Style = "List Paragraph"
       End If
    Next
    End Sub

    You do not actually need to Select anything.


    Word MVP

    • Proposed as answer by fumei2 Saturday, August 18, 2012 11:28 PM
    • Marked as answer by Quist Zhang Sunday, August 26, 2012 5:46 PM
    Friday, August 17, 2012 11:03 PM