Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding automatic bullets and numbers

    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

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Finding automatic bullets and numbers

    Troy,

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

    <pre>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</pre>

    Gary

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding automatic bullets and numbers

    <P ID="edit"><FONT SIZE=-1>Edited by TroyWells on 01/04/17 23:59.</FONT></P> <img src=/S/joy.gif border=0 alt=joy width=23 height=23>Gary, YOU MADE MY DAY!!!!!!!
    This worked perfectly.
    <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>EXCEPT...
    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

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Finding automatic bullets and numbers

    Troy,

    Glad this worked for you. <img src=/S/cool.gif border=0 alt=cool width=15 height=15>
    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

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding automatic bullets and numbers

    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.

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Finding automatic bullets and numbers

    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!<g>

    <pre>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</pre>


  7. #7
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding automatic bullets and numbers

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

    Troy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •