Written by Allen Wyatt (last updated December 7, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021
Michele needs a way to count the number of bulleted lists or the number of numbered lists in a document. She wonders how this could be accomplished in Word.
This is a bit harder than one might imagine, the bottom line being that we can find no way to generate a count reliably. The reason for this may take a bit of explaining.
There are multiple ways you can add styles to your document. For instance, you could click on either the Numbered List or Bulleted List tools on the Home tab of the ribbon to convert the current paragraph (or paragraphs) to a list. You could also start typing and allow Word to detect (via AutoFormat As You Type) whether you are creating a numbered list or a bulleted list. You could even define and apply styles that designate what you want used as a list.
Regardless of the way you create your lists, Word associates a style with the paragraphs in the list. If you create and apply your own style, then that particular style is (of course) used. If you use the toolbar buttons or rely on AutoFormat to create the lists, then Word automatically applies the List Paragraph style. (Yes, it uses the exact same style regardless of whether it is a numbered or bulleted list.)
Since styles are associated with the list, you can quickly determine how many instances of the style are in use. All you need to do is to display the Styles task pane (display the Home tab of the ribbon and click the small icon at the bottom-right of the Styles group). Locate the style used for your lists, hover the mouse pointer over that style name, and then click the down-arrow that appears to the right of the name. You'll see something similar to one of the following appear:
If what you see matches the first format, then select that option. When you hover over the style name and click the down-arrow again, what you see should match the second format.
You might think that this shows you the number of lists in your document. It doesn't; it only shows you the number of paragraphs formatted with this particular style. Thus, if you have a single list that is comprised of 6 items, then the style count returned will be 6. Thus, this approach—counting styles—doesn't provide a reliable way to determine a list count.
The other way you might consider is to use a macro to determine how many lists are in your document. Word maintains a Lists collection and makes it available to VBA. You can step through each list in the document and examine its ListType property. This property can actually be one of seven different values, as indicated by the following enumerations:
You can probably figure out what each of these lists types entails, but how they play out in reality can be a bit perplexing. As an example, consider the following macro:
Sub CheckLists() Dim oL As List Dim sMsg As String Dim J As Integer Dim K As Integer J = ActiveDocument.Lists.Count For Each oL In ActiveDocument.Lists K = K + 1 oL.Range.Select sMsg = "This is list " & K & " of " & J sMsg = sMsg & " lists in the document." & vbCrLf & vbCrLf sMsg = sMsg & "This list is this type: " Select Case oL.Range.ListFormat.ListType Case wdListBullet sMsg = sMsg & "wdListBullet" Case wdListListNumOnly sMsg = sMsg & "wdListListNumOnly" Case wdListMixedNumbering sMsg = sMsg & "wdListMixedNumbering" Case wdListNoNumbering sMsg = sMsg & "wdListNoNumbering" Case wdListOutlineNumbering sMsg = sMsg & "wdListOutlineNumbering" Case wdListPictureBullet sMsg = sMsg & "wdListPictureBullet" Case wdListSimpleNumbering sMsg = sMsg & "wdListSimpleNumbering" End Select MsgBox sMsg Next oL End Sub
If you have a document that contains lists and run this, it will select each list, in turn, and display a message box that shows what type of list Word thinks the selection represents. The problem is, if your text contains two lists interspersed by a paragraph or two of text, Word considers it a single list of the wdListMixedNumbering type. In other words, it doesn't accurately figure out what is a list and what isn't a list. This makes this particular approach unreliable for counting how many lists are in your document, although it is more accurate than using the count-the-styles approach.
The bottom line, as mentioned at the beginning, is that there is no way that we can determine to accurately count the number of bulleted and numbered lists in a document.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13528) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
If you have lists in your document, either bulleted or numbered, you may want to change them back to regular text at some ...
Discover MoreThere are two types of common lists you can use in a document: bulleted lists and numbered lists. This tip explains the ...
Discover MoreThere are two types of common lists you can create in Word: bulleted lists and numbered lists. You can switch between the ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-12-09 11:27:25
Andrew
A couple of thoughts:
1. I disagree that a list interspersed with non-list paragraphs shouldn't be considered a single list. In my opinion, a single list should comprise a single uninterrupted number schema -- e.g., why shouldn't a single list item be able to contain multiple paragraphs, a table, etc.?
2. Ditto what Ken Endacott said. On reading this post, I immediately thought there must be a heuristic way to do a count, so I though, why not just count the number of paragraphs that are first in a list. Well ... I quickly ran into 1) Ken's issue regarding infinite list formats; 2) Word's making it easier to identify "last" paragraphs as opposed to "first" paragraphs (e.g., if LP is a Paragraph in the ActiveDocument.ListParagraphs collection, testing for LP.Range.CanContinuePreviousList(LP.Range.ListTemplate) = wdContinueDisabled) -- not a problem in and of itself, for single "list" a "disabled" continuation is signaled at each change of level; 3) etc. etc.
Andy.
2024-12-08 02:56:17
Ken Endacott
Microsoft have excelled themselves in the implementation of List numbering. It is complex, inconsistent and difficult to use. The complexity increased ten fold when they introduced numbering buttons on the Home ribbon.
Several thousand lines of VBA code and many hours of work and I have ended up with comprehensive macros that pull apart lists and identify the paragraphs and styles to which they apply.
A surprise is that new List Templates are created just about every time changes are made, the old ones are never deleted but just sit there unused. I have seen a heavily edited document with over 200 dormant List Templates.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments