• ListType Confusion (VBA for Word 97/2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » ListType Confusion (VBA for Word 97/2000)

    Author
    Topic
    #363943

    Sorry to keep choking up the forum with questions, but I’m getting down to the wire on a project and keep hitting some bring walls.

    I can’t seem to get the ListType property to work like I have seen example of in this forum and the online help. Consider the following line of code:

    MsgBox DocThis.Paragraphs(N).Range.ListFormat.ListType

    You would think this would give you one of the constants such as “wdListBullet” or “wdListSimpleNumbering” or “wdListOutlineNumbering”. Instead it gives a constant that I can’t seem to get to come up consistently between the various galleries. For instance, I once got a msgbox of “4” for both a bulleted and for an outline numbered paragraph.

    Also I have similar statement:

    If DocThis.Paragraphs(N).Range.ListFormat.ListType = wdListBullet Or _
    wdListSimpleNumbering Or wdListOutlineNumbering Then

    That should not fire if the text is not a numbered or bulleted list, but the procedure goes forward as if it is true, even for regular nonlist paragraphs.

    What I want to determine is if the automatic list is using numbers or bullets or if there is no numbering. This should not be that difficult, but brickwall.

    Thanks for your help!!
    Troy

    Viewing 0 reply threads
    Author
    Replies
    • #557384

      > If DocThis.Paragraphs(N).Range.ListFormat.ListType = wdListBullet Or _
      > wdListSimpleNumbering Or wdListOutlineNumbering Then

      You cannot use Or this way; you must spell out the full expression between Ors, or it won’t give the expected results.

      • #557393

        Edited by TroyWells on 11-Dec-01 04:13.

        This problem seems to only occur with me in Word 2000

        While I’m sure what you said is correct, try the following code:

        If ActiveDocument.Paragraphs(1).Range.ListFormat.ListType = wdListBullet Then
        MsgBox “Bullets”
        ElseIf ActiveDocument.Paragraphs(1).Range.ListFormat.ListType = wdListSimpleNumbering Then
        MsgBox “Simple”
        ElseIf ActiveDocument.Paragraphs(1).Range.ListFormat.ListType = wdListOutlineNumbering Then
        MsgBox “Outline”
        End If

        WITH the following experiment:

        1. Format > Bullets and Numbering; pick the first gallery selection under the Bulleted tab; run code.

        2. Format > Bullets and Numbering; pick the first gallery selection under the Numbered tab; run code.
        (At this point it told me I had outline numbering)

        3. Format > Bullets and Numbering; pick the first gallery selection under the Numbered tab; run code.
        (At this point it told me I had outline numbering)

        Repeat steps 1 through 3 and mix them up. See if it gives answers as inconsistently for you as it did me.

        All I want is to find out which Gallery was used to format the number (mainly whether it is bullets or numbers or none). ListType should work, but it doesn’t for me.

        Thanks!!
        Troy

    Viewing 0 reply threads
    Reply To: ListType Confusion (VBA for Word 97/2000)

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

    Your information: