• Finding automatic bullets and numbers

    Author
    Topic
    #355093

    I’m using Word 97 and want to create a macro that finds any automatic bulleted paragraph (i.e. a paragraph created in the Normal style by clicking on the Bullets toolbar button).

    Similarly I want to find all automatic numbered paragraphs (i.e. a paragraph created in the Normal style by clicking on the Numbering toolbar button).

    I hope to replace these with FindWhatText in a specific style. I know how to do the replace part, just not the find. This is an output of a conversion from an HTML-based help file that I want to format using styles.

    Thanks for any help you can give!!
    Troy

    Viewing 0 reply threads
    Author
    Replies
    • #523137

      Troy,

      Here’s one way to do it (if I understand the request correctly):

      Sub FindBulletedORNumberedParas()
      Dim aPara As Paragraph
      For Each aPara In ActiveDocument.Paragraphs
          If aPara.Style = "Normal" Then
              If aPara.Range.ListFormat.ListType = wdListBullet Then
                  aPara.Range.ListFormat.RemoveNumbers
                  aPara.Style = "Block Text" 'substitute your style name here
              ElseIf aPara.Range.ListFormat.ListType = wdListSimpleNumbering Then
                  aPara.Range.ListFormat.RemoveNumbers
                  aPara.Style = "Block Text" 'substitute your style name here
              End If
          End If
      Next aPara
      End Sub

      Gary

      • #523142

        Edited by TroyWells on 01/04/17 23:59.

        joyGary, YOU MADE MY DAY!!!!!!!
        This worked perfectly.
        shrugEXCEPT…
        After running this I realized I needed one more IF statement. I am not a VB programmer and could not figure out how to add this particular IF statement.

        On most lines for the bulleted lists, if on the Format menu, I click Paragraph, the Left Indent is 18 pt, and the same with the numbered list. There are some exceptions for a second level of bullets and a second level of numbering.

        If you can get me started with how to put this particular IF statement into the macro you sent, I can take it from there. I think I am mainly hung up on the syntax of this particular property.

        Thanks again!!
        Troy

        • #523147

          Troy,

          Glad this worked for you. cool
          As far as the additional If statements, can you clarify – is it:

          Case A: you want the paragraphs with Left indent of 18pts to get changed to one particular style, and you want the paragraphs with other indenting to get changed to a second particular style OR

          Case B: you want the paragraphs with Left indent of 18pts to get changed to one particular style, and you want the paragraphs with other indenting to be left alone i.e. bullets or numbering intact.

          (BTW this is a perfect time to mention that styles are really the way to go when setting up formatting – if these bulleted and numbered paragraphs had been set up with styles to begin with, changing their attributes now would be a relative snap (via a visit to Format>Style>Modify>Numbering – no macro would be required.)

          Gary

          • #523149

            It would be Case A: (I want the paragraphs with Left indent of 18pts to get changed to one particular style, and I want the paragraphs with other indenting to get changed to a second particular style).

            Thanks!!
            P.S. The whole reason for this macro is to apply styles so I don’t need a macro in the future. Unfortunately, I cannot add styles in these particular HTML help files ahead of time.

            • #523151

              Hi again,

              OK, the following should work.
              One thing to note: the indent value of “18” that’s in the code, may need to be adjusted depending on whether the paragraphs feature a hanging indent. For instance, if they have a left indent of 18 and a hanging indent of 18, you need to change the LeftIndent value to 36 for it to work.

              Re: PS and styles: I guess you did say these were coming from HTML in the first place!

              Sub FindBulletedORNumberedParas2()
              Dim aPara As Paragraph
              For Each aPara In ActiveDocument.Paragraphs
                  If aPara.Style = "Normal" Then
                      If aPara.Range.ListFormat.ListType = wdListBullet Then
                          If aPara.LeftIndent = 18 Then 'if hanging indent of 18, make this 36
                              aPara.Range.ListFormat.RemoveNumbers
                              aPara.Style = "Body Text Indent" 'substitute your style name here
                          Else
                              aPara.Range.ListFormat.RemoveNumbers
                              aPara.Style = "Body Text Indent 2"
                          End If
                      ElseIf aPara.Range.ListFormat.ListType = wdListSimpleNumbering Then
                          If aPara.LeftIndent = 18 Then 'if hanging indent of 18, make this 36
                              aPara.Range.ListFormat.RemoveNumbers
                              aPara.Style = "Body Text Indent" 'substitute your style name here
                          Else
                              aPara.Range.ListFormat.RemoveNumbers
                              aPara.Style = "Body Text Indent 2"
                          End If
                      End If
                  End If
              Next aPara
              End Sub
            • #523236

              That did the trick. Thank you so much for your help!!

              Troy

    Viewing 0 reply threads
    Reply To: Finding automatic bullets and numbers

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: