-
selectin multi-level list items
Hello,
I am having problem iterating over list in VBA Macro and selecting list items including sub-list items if any.
Essentially I need to iterate over first select level items, select each item and apply tag to the selection, if item has nested subsists I need to select them as well.
The code I use is
Dim para As Paragraph
For Each para In selection.Paragraphs
If para.range.ListFormat.ListType = wdListListNumOnly Or _
para.range.ListFormat.ListType = wdListBullet Or _
para.range.ListFormat.ListType = wdListSimpleNumbering Or _
para.range.ListFormat.ListType = wdListOutlineNumbering Or _
para.range.ListFormat.ListType = wdListMixedNumbering Or _
para.range.ListFormat.ListType = wdListPictureBullet Then
para.range.Select
Call MARK_SELECTION(para.range, para.range.ListFormat.ListValue)
End If
rng.Select
Next para
The problem with this code is that when list item has subsist the selection is treating subsist items as distinct Paragraphs, but I need to include the selection with first level item. So Item 2 selection should include sub-items (a, b, c, d)
list sample:
1. Item 1
2. Item 2
a. Sub item 1
b. Sub item 2
c. Sub item 3
d. Sub item 5
3. Item 3
4. Item 4
a. Sub item 1
b. Sub item 2
c. Sub item 3
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules