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

    ListType Confusion (VBA for Word 97/2000)

    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 <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>.

    Thanks for your help!!
    Troy

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ListType Confusion (VBA for Word 97/2000)

    > 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.

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

    Re: ListType Confusion (VBA for Word 97/2000)

    <P ID="edit" class=small>Edited by TroyWells on 11-Dec-01 04:13.</P>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.List Type = wdListBullet Then
    MsgBox "Bullets"
    ElseIf ActiveDocument.Paragraphs(1).Range.ListFormat.List Type = wdListSimpleNumbering Then
    MsgBox "Simple"
    ElseIf ActiveDocument.Paragraphs(1).Range.ListFormat.List Type = 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

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ListType Confusion (VBA for Word 97/2000)

    I also get 4 every time. Getting the Range.ListFormat.ListType from the ListParagraphs collection yielded the same wrong answer. Bummer.

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

    Re: ListType Confusion (VBA for Word 97/2000)

    Was that on Word 97 or Word 2000?

    Troy

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ListType Confusion (VBA for Word 97/2000)

    Word 2000.

Posting Permissions

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