Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find/Goto a bullet number in Word

Status
Not open for further replies.

sxschech

Technical User
Jul 11, 2002
1,033
US
Maybe used the wrong search terms...Is there a method to find a bullet number the way you use ctrl+F to find words in MS-Word or do I have to convert bullets to text, which I'd prefer not to do since then I'd have to either close and reopen or reconvert to bullets. Example there are items numbered from 1 to 100 spread over 34 pages. How to go to or find number 50?
 
There's no built-in method, no. But this can be solved with a little bit of VBA. Have a look at the Find object and a Range's ListFormat.ListString property.
 
In fact, here's a quick example I' ve cobbled together to illutrate the idea (which makes the assumption that you have a particular style assigned to the list items, which should be the c ase if you are using Word's automatic listing capablityies and/or the the numbered list button:

Code:
[blue]Public Sub FindListItem(strlistItem As String)
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("List Paragraph")
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Do
        Selection.Find.Execute
    Loop Until Selection.Range.ListFormat.ListString = strlistItem Or Selection.Find.Found = False
End Sub

Public Sub example()
    FindListItem "3)"
End Sub[/blue]
 
Hi Strongm,

Thank you for looking at this.

Your code worked on a file that used the list paragraph style. Thanks.

The files that I am currently working on, which is where I'm trying to find the bullet numbers, were set up with a different style. I had hoped that simply changing the style would do the trick, but didn't.

As these are files we receive from various sources and each one has their own style, for the doc I'm currently reviewing, I clicked on the text and popped open the styles dialogue to see what its style was and it showed Level 2 Text. I changed [tt]Selection.Find.Style = ActiveDocument.Styles("List Paragraph")[/tt] to [tt]Selection.Find.Style = ActiveDocument.Styles("Level 2 Text")[/tt] and then ran it. It went through the whole document and ended on the last paragraph rather than the number I chose. I noticed that the numbers were bolded and saw there was a style called Level 2 Text + Bold. Tried that and it errored on [tt]Selection.Find.Style = ActiveDocument.Styles("Level 2 Text + Bold")[/tt]
5941. The requested member of the collection does not exist.
Clicking the paragraph does not show any of the list types as clicked, the abcd portion within it does show the 123 button as clicked. As not so familiar with word, not sure how the person created the numbered list. If I click an insertion point before the number and hit enter, it does not increment, if I click an insertion after the letters it does.

 
As I say, it was just an illustraton of the basic idea. Here's a moinor tweak that doesn't care about the paragraph style. Again, this is not a final, production-ready solution (e.g. doesn't handle the scenario where the list item is not found):

Code:
[blue]Public Sub FindListItem(strlistItem As String)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = "*^13"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Do
        Selection.Collapse wdCollapseEnd
        Selection.Find.Execute
        Selection.Expand wdParagraph
    Loop Until Selection.Range.ListFormat.ListString = strlistItem Or Selection.Find.Found = False
End Sub[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top