Go to the next paragraph with bullet

H

hans.list

Hi,

Is it possible to go from the current cursor position in a document to the first paragraph of the next bulleted list (that makes the Bullet list item on the ribbon light)?

Thans,

Hans
 
H

hans.list

This puts the cursor at the start of the first paragraph with a bullet:

Dim myPar As Paragraph

For Each myPar In ActiveDocument.Paragraphs

If myPar.Range.ListFormat.ListType = wdListBullet Then
myPar.Range.Select
Selection.Collapse
End
End If

Next myPar

How can I make the macro remember the paragraph number, that is: if I start it again, it should go to the next bulleted range.
 
B

Barry Schwarz

This puts the cursor at the start of the first paragraph with a bullet:

Dim myPar As Paragraph

For Each myPar In ActiveDocument.Paragraphs

If myPar.Range.ListFormat.ListType = wdListBullet Then
myPar.Range.Select
Selection.Collapse
End
End If

Next myPar

How can I make the macro remember the paragraph number, that is: if I start it again, it should go to the next bulleted range.

Obtain the number of paragraphs in the document.
Set an initial paragraph variable to 0.
Change the For Each to loop on an index ranging from initial paragraph
variable to number of paragraphs.
When the if is satisfied, save the current loop index +1 in the
initial paragraph variable.
 
B

Barry Schwarz

Thanks! How can I start the For each loop at a certain paragraph number?

By definition, For Each will always start at the first paragraph.
Otherwise, it would be For Some.

Instead of For Each, loop on a paragraph index. You can set the
starting and ending values of the index to any value you like,
constant or computed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top