Go to the next paragraph with bullet

Discussion in 'Word VBA' started by hans.list@gmail.com, Nov 22, 2013.

  1. Guest

    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
     
    , Nov 22, 2013
    #1
    1. Advertisements

  2. Guest

    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.
     
    , Nov 27, 2013
    #2
    1. Advertisements

  3. On Wed, 27 Nov 2013 12:24:13 -0800 (PST), wrote:

    >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.

    --
    Remove del for email
     
    Barry Schwarz, Nov 28, 2013
    #3
  4. Guest

    Thanks! How can I start the For each loop at a certain paragraph number?
     
    , Nov 28, 2013
    #4
  5. On Thu, 28 Nov 2013 09:10:08 -0800 (PST), wrote:

    >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.

    --
    Remove del for email
     
    Barry Schwarz, Nov 28, 2013
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.