Word VBA to capture orphaned bullets

Kuljack

Active Member
Joined
Aug 14, 2015
Messages
327
Hello again,

I received great success with a previous post on Word VBA, so I am moving to my next inquiry.

Is it possible for Word VBA to scan a document and highlight the following scenario:

-A bullet cannot stand alone as an individual set, regardless of sub-bullets

The goal here is to capture throughout a document any scenario where a bullet at any level within the bullet chain does not have a subsequent bullet. An example is provided below of what to capture.


Edit/Note: Due to constraints in the forum font formats, the sub bullets in the examples below should be seen as "a./b." per directions in bold, I've added them in parenthesis for better identification.

In this example, the first level of bulleting is invalid because "1." is not followed by a "2.", the sub bullets are acceptable because "a." is followed by a "b." but the entire section is still invalid because the parent bullet holds the error.
  1. This is the main sentence​
    1. (a.) Followed by a sub sentence​
    2. (b.) Followed by another sub sentence
For the above example, I would just like the parent bullet to be highlighted and let the user address the corrections, like so (text is highlighted in example, but I aim to use the background highlight function in Word):

  1. This is the main sentence
    1. (a.)Followed by a sub sentence​
    2. (b.)Followed by another sub sentence​

In this example, the first level of bulleting is valid because "1." is followed by a "2.", however; the second level of bulleting is invalid because the "a." stands without a "b." and should be called out similarily.



  1. This is another scenario​
    1. (a.) Where this is wrong​
  2. However, 1 and 2 are okay
So in this example, the bullet of "a." would need to be called out, while the parent bullets remain undeteced.​


  1. This is another scenario​
    1. (a.) Where this is wrong
  2. However, 1 and 2 are okay

I am betting that I am being optimistic here, but hoping that it's a simple effort to somehow script in VBA "If ever a bullet is orphaned, I.E. stands alone without a subsequent bullet, capture the bullet with a highlight marking".

Additionally, is it possible to address the formatting of these bullets? There are strict guidelines where the user can only use the following structure for bulleting:


  1. Numerical value followed by period
    1. (a.) Lower-case letter followed by period
      1. Numerical value followed by period
        1. (a.) Lower-case letter followed by period

The user is restricted from use of fancy bullet objects, roman numerals, upper-case lettering, and all other means. The only exception to this are open/closed bullets if being used for various lists that have no chronological order.


Thank-you for any assistance!


Edit: Using Microsoft Word 2010
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If you're using Styles for the formatting (as you should be), it's a simple matter to use a macro to find all content in a given style (which it will do on a per-paragraph basis) and test whether the previous or next paragraph is of the same Style or a related Style. The issue with 'related' Styles, though, is that scenarios like you've posed can require a fair bit of looking forward/backward to establish whether the hierarchy is correct. So, yes, it's doable, but it's not trivial. And then there's the question of what you might want to do once you've found something that doesn't conform...

If you're not using Styles, this rapidly gets quite difficult.
 
Upvote 0
Thank you!

I'll look into this given the premises you've provided to begin with. I appreciate the direction.
 
Upvote 0
By chance do you have an example of what this approach may look like? I'm not savvy with Word VBA, the language is confusing and I've not spent much time writing in it.

All I would need it to do with an error found is highlight the bullet/row of text.

I'm assuming Styles is just referring to the use of preformatted bulleting provided by MS Word, if so then yes, Styles are certainly being used here.
 
Upvote 0
No, I don't have any such code to hand. And, as I said, writing it wouldn't be a trivial undertaking.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top