I’m trying to take a numbered list created in Outlook and manipulate it based on the top-level list items. Unfortunately, the only way I’ve found to manipulate the list is through the ListParagraph type, which breaks out all list items (including sub-items) equally, instead of having different access for each level in the list.
Is there a way to access, in one object, a list item, along with all its sub-items?
Thanks.
Here’s what I’m currently using, which works fine for lists with only one level of items:
While i <= oMeetingWordDoc.Lists(1).ListParagraphs.Count
Set oRange = oMeetingWordDoc.Lists(1).ListParagraphs(i).Range
*Perform actions with oRange
i = i + 1
wend
By lists with ‘one level’ I mean something like this:
- Item 1
- Item 2
- Item 3
By lists with ‘sub-items’ I mean something like this:
-
List item 1
a) Item a
b) Item b
c) Item c -
Item 2
a) Item a
b) Item b -
Item 3
a) Item a
ListFormat.ListLevelNumberis what you’re looking for. Here is some code that will output the list level and text of everyListParagraphin the document:You can of course use the condition of
ListLevelNumber = 1to access only top level lists,ListLevelNumber = 2for second level, etc.I don’t really think there’s a great way to do this, unless you build it yourself using recursion or something (create an object with an array of children, and each child with it’s own array of children, etc.). I don’t have this coded up, but hopefully the code I posted will let you accomplish what you want to do- and it’s much simpler.
Also,
ListFormatalso has some other members that may be useful if you’re doing a lot with lists- dig around in the Object Browser to learn more.